关于spring boot 中App类位置不同导致出错的问题的解决方法

来源:互联网 发布:云计算的具体应用 编辑:程序博客网 时间:2024/05/18 02:13

@Configuration @EnableAutoConfiguration @ComponentScan这三个注解默认以main class所在目录作为根节点扫描classpath. @ComponentScan扫描组件,比如@Service,@Configuration等,@EnableAutoConfiguration扫描@Entity。

@SpringBootApplication的作用和以上三个注解等同。main class路径改变,也就是说Entity没有被扫描到。

解决办法:    https://stackoverflow.com/questions/30587377/springboot-componentscan-issue-with-multi-module-project

相关文档:1. https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-using-springbootapplication-annotation.html

                       2. https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-structuring-your-code.html

阅读全文
0 0
原创粉丝点击