admin管理员组

文章数量:1794759

springboot启动报Consider defining a bean of type 'xxx' in your configuration的错

springboot启动报Consider defining a bean of type 'xxx' in your configuration的错

1.问题描述: springboot在启动过程中报:Consider defining a bean of type ‘xxx’ in your configuration的错 2.项目的目录结构图如下: 3.问题分析: @EnableAutoConfiguration注解上标注了两个注解,@AutoConfigurationPackage、@Import。@Import注解在SpringIOC一些注解的源码中比较常见,主要用来给容器导入目标bean。这里@Import注解给容器导入的组件用于自动配置:AutoConfigurationImportSelector ; 而@AutoConfigurationPackage注解试Spring自定义的注解,用于扫描启动类所在的包及其子包下的自定义类。

因为springboot启动时扫描不到对应的service,所以导致注入属性失败。 4.问题解决方案: 移动启动类至最外层的包,这样 【@AutoConfigurationPackage注解试Spring自定义的注解,用于扫描启动类所在的包及其子包下的自定义】 就会生效 5.参考文章链接 blog.csdn/zhoushimiao1990/article/details/90258014

本文标签: beantypeSpringBootdefiningxxx