在service中注入时,报错:Could not autowire. No beans of xxx
只是报错,不影响运行。
因为没有声明这个DAO接口作为Spring的Bean,因此Spring不能进行管理,导致注入报错。
解决办法
只需在DAO接口加上@Component 或者 @Repository(@Repository实际上也包含了@Component注解)注解声明为Spring的Bean即可。
在service中注入时,报错:Could not autowire. No beans of xxx
只是报错,不影响运行。
因为没有声明这个DAO接口作为Spring的Bean,因此Spring不能进行管理,导致注入报错。
解决办法
只需在DAO接口加上@Component 或者 @Repository(@Repository实际上也包含了@Component注解)注解声明为Spring的Bean即可。