英文:
ComponentScan or EntityScan don't find entities in another project
问题
我有一个 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 目录中删除这些项目,但是我始终得到相同的错误(作为截图附加)[stacktrace][1]
[1]: https://i.stack.imgur.com/6U712.jpg
英文:
I have spring boot project in which I import entities from my other spring boot project.
Dependence on a project with entities is as follows
<dependency>
<groupId>models</groupId>
<artifactId>models</artifactId>
<version>0.2</version>
</dependency>
The main project is configured as follows
@SpringBootApplication
@EnableDiscoveryClient
@EnableZuulProxy
@ComponentScan(basePackages = "model.entity")
public class SecurityService {
public static void main(String[] args) {
run(SecurityService.class, args);
}
}
I've tried using @ComponentScan and @EntityScan. I tried to delete these projects from the .m2 directory but I always get the same error (attach as screeshoot) stacktrace
答案1
得分: 1
这是我的错误,我忘记添加
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
英文:
it is my mistake, I forgot add
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论