为了账号安全,请及时绑定邮箱和手机立即绑定

Spring boot (2.0.4.RELEASE) - IllegalArgument

Spring boot (2.0.4.RELEASE) - IllegalArgument

翻阅古今 2021-08-25 17:07:54
我正在使用 spring boot 应用程序尝试连接手动数据源,运行项目时出现异常:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accountController': Unsatisfied dependency expressed through field 'accountService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accountServiceImpl': Unsatisfied dependency expressed through field 'accountDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountDao': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.springstudy.demo.model.Account    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1341) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
查看完整描述

3 回答

?
慕姐8265434

TA贡献1813条经验 获得超2个赞

将以下注释添加到您的配置类:

@EntityScan(basePackages = {"<package-name>"})


查看完整回答
反对 回复 2021-08-25
?
慕田峪9158850

TA贡献1794条经验 获得超7个赞

我对 Spring Boot 2.1.5 有同样的问题。问题是我使用了 Pervasive Database 的 JDBC 驱动程序。

所以,我必须在 build.gradle 中包含 Spring Data JDBC Support

implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'

这解决了我的问题。


查看完整回答
反对 回复 2021-08-25
  • 3 回答
  • 0 关注
  • 224 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信