admin管理员组文章数量:1794759
spring boot自动注入出现Consider defining a bean of type 'xxx' in your configuration的问题
在搭建一个简单的关于springboot的AOP编程时,遇到一个Consider defining a bean of type ‘com.springboot.chapter04.service.impl.UserServiceImpl’ in your configuration的问题。
Description: Field helloService in com.example.demo.service.TestController required a bean of type 'com.springboot.chapter04.service.impl.UserServiceImpl' that could not be found. Action: Consider defining a bean of type 'com.springboot.chapter04.service.impl.UserServiceImpl' in your configuration.最后找到问题,就是springboot启动类包扫描的路径和我接口实现类的路径不是在同一个目录中 解决办法是将启动类包扫描的路径改成与实现类相同的路径 实现类的路径是
package com.springboot.chapter04.service.impl; @SpringBootApplication(scanBasePackages = "com.springboot.chapter04")这样做的一个缺点是将一些不需要注入的类也一起注入了 另一个方法是将实现类移到启动类的同一个路径下或者子路径下
本文标签: definingbeanspringboottype
版权声明:本文标题:spring boot自动注入出现Consider defining a bean of type 'xxx' in your configuration的问题 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1686551951a80982.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论