因默认包扫描问题导致的SpringBoot项目无法启动问题

时间:2022-06-03 07:32:15

启动SpringBoot项目的时候,提示如下信息:

-- ::22.255  INFO  --- [           main] s.c.a.AnnotationConfigApplicationContext : 
Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@4e3958e7:
startup date [Mon Aug :: CST ]; root of context hierarchy
-- ::22.817 INFO --- [ main] f.a.AutowiredAnnotationBeanPostProcessor :
JSR- 'javax.inject.Inject' annotation found and supported for autowiring
-- ::22.864 INFO --- [ main] trationDelegate$BeanPostProcessorChecker :
Bean 'configurationPropertiesRebinderAutoConfiguration' of type
[class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$105a6ef0]
is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) . ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.4.2.RELEASE) -- ::23.551 INFO --- [ main] EurekaServerMasterApplication :
No active profile set, falling back to default profiles: default
-- ::23.567 INFO --- [ main] ationConfigEmbeddedWebApplicationContext :
Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@12c7a01b:
startup date [Mon Aug :: CST ];
parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@4e3958e7
-- ::23.582 WARN --- [ main] ionWarningsApplicationContextInitializer : ** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.

解决办法:

把main方法所在的类放到一个自定义的包路径下,而不能直接放在mian/java路径下。

下面是错误的位置:

因默认包扫描问题导致的SpringBoot项目无法启动问题

下面是正确的位置:

因默认包扫描问题导致的SpringBoot项目无法启动问题

如果本文对您有所帮助,请扫描下方微信二维码打赏,您的鼓励是我前进最大的鼓励!

因默认包扫描问题导致的SpringBoot项目无法启动问题