【问题标题】:ComponentScan or EntityScan don't find entities in another projectComponentScan 或 EntityScan 在另一个项目中找不到实体
【发布时间】:2021-01-07 17:40:18
【问题描述】:

我有一个 spring boot 项目,我从我的其他 spring boot 项目中导入实体。

对一个有实体的项目的依赖如下

    <dependency>
        <groupId>models</groupId>
        <artifactId>models</artifactId>
        <version>0.2</version>
    </dependency>

主工程配置如下

@SpringBootApplication
@EnableDiscoveryClient
@EnableZuulProxy
@ComponentScan(basePackages = "model.entity")
public class SecurityService {
    public static void main(String[] args) {
        run(SecurityService.class, args);
    }
}

我尝试过使用@ComponentScan 和@EntityScan。我试图从 .m2 目录中删除这些项目,但我总是得到相同的错误(附加为 screeshoot)stacktrace

【问题讨论】:

  • 也许你必须从依赖项中指定包名

标签: java spring spring-boot maven jpa


【解决方案1】:

是我的错,我忘了加

<dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>

【讨论】:

    猜你喜欢
    • 2016-12-18
    • 2020-04-09
    • 1970-01-01
    • 2011-09-08
    • 1970-01-01
    • 2022-07-06
    • 1970-01-01
    • 2019-07-25
    相关资源
    最近更新 更多