ComponentScan或EntityScan在另一个项目中无法找到实体。

huangapple go评论94阅读模式
英文:

ComponentScan or EntityScan don't find entities in another project

问题

  1. 我有一个 Spring Boot 项目在这个项目中我从另一个 Spring Boot 项目中导入实体
  2. 对于依赖于包含实体的项目配置如下
  3. <dependency>
  4. <groupId>models</groupId>
  5. <artifactId>models</artifactId>
  6. <version>0.2</version>
  7. </dependency>
  8. 主项目的配置如下
  9. @SpringBootApplication
  10. @EnableDiscoveryClient
  11. @EnableZuulProxy
  12. @ComponentScan(basePackages = "model.entity")
  13. public class SecurityService {
  14. public static void main(String[] args) {
  15. run(SecurityService.class, args);
  16. }
  17. }
  18. 我尝试过使用 @ComponentScan @EntityScan我也尝试过从 .m2 目录中删除这些项目但是我始终得到相同的错误作为截图附加[stacktrace][1]
  19. [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

  1. &lt;dependency&gt;
  2. &lt;groupId&gt;models&lt;/groupId&gt;
  3. &lt;artifactId&gt;models&lt;/artifactId&gt;
  4. &lt;version&gt;0.2&lt;/version&gt;
  5. &lt;/dependency&gt;

The main project is configured as follows

  1. @SpringBootApplication
  2. @EnableDiscoveryClient
  3. @EnableZuulProxy
  4. @ComponentScan(basePackages = &quot;model.entity&quot;)
  5. public class SecurityService {
  6. public static void main(String[] args) {
  7. run(SecurityService.class, args);
  8. }
  9. }

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

这是我的错误,我忘记添加

  1. <dependency>
  2. <groupId>mysql</groupId>
  3. <artifactId>mysql-connector-java</artifactId>
  4. </dependency>
英文:

it is my mistake, I forgot add

  1. &lt;dependency&gt;
  2. &lt;groupId&gt;mysql&lt;/groupId&gt;
  3. &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
  4. &lt;/dependency&gt;

huangapple
  • 本文由 发表于 2020年9月21日 23:32:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/63995453.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定