admin管理员组文章数量:1794759
spring boot jpa启动错误Consider defining a bean of type ‘com.example.security.dao.UserDao‘
spring boot 启动类不在根目录整合spring boot jpa启动报错:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2020-12-02 17:14:08.940 ERROR 3868 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: Parameter 0 of constructor in com.example.security.service.UserServiceImpl required a bean of type 'com.example.security.dao.UserDao' that could not be found. Action: Consider defining a bean of type 'com.example.security.dao.UserDao' in your configuration. Disconnected from the target VM, address: '127.0.0.1:52540', transport: 'socket' Process finished with exit code 1解决方法: 1、需要在启动类加上以下注解 @EnableJpaRepositories(basePackages = {“com.example.security”}) @EntityScan(basePackages = {“com.example.security”})
/** * {@link EnableJpaRepositories} 扫描 @Repository 注解 * {@link EntityScan} 扫描 @Entity 注解 * {@link ComponentScan}扫描 @Controller、@Service 注解 * @author */ @SpringBootApplication @EnableJpaRepositories(basePackages = {"com.example.security"}) @EntityScan(basePackages = {"com.example.security"}) @ComponentScan({"com.example.security"}) public class BootStartApplication { public static void main(String[] args) { SpringApplication.run(BootStartApplication .class, args); } }2、将启动类移至项目根目录
参考博客:blog.csdn/guokexiaohao/article/details/79741023
版权声明:本文标题:spring boot jpa启动错误Consider defining a bean of type ‘com.example.security.dao.UserDao‘ 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1686554490a81265.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论