Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package
报错原因
项目启动Application没有和类处在同一个目录下,导致扫描不到类
报错信息
D:\DevelopTools\java\jdk1.8.0_231\bin\java.exe -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.5\lib\idea_rt.jar=54649:C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.5\bin" -Dfile.encoding=UTF-8 -classpath D:\DevelopTools\java\jdk1.8.0_231\jre\lib\charsets.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\deploy.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\ext\access-bridge-64.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\ext\cldrdata.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\ext\dnsns.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\ext\jaccess.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\ext\jfxrt.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\ext\localedata.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\ext\nashorn.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\ext\sunec.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\ext\sunjce_provider.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\ext\sunmscapi.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\ext\sunpkcs11.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\ext\zipfs.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\javaws.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\jce.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\jfr.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\jfxswt.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\jsse.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\management-agent.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\plugin.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\resources.jar;D:\DevelopTools\java\jdk1.8.0_231\jre\lib\rt.jar;H:\Dev_projects\das\java_demo\interceptor\target\classes;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\springframework\boot\spring-boot-starter\2.3.2.RELEASE\spring-boot-starter-2.3.2.RELEASE.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\springframework\boot\spring-boot\2.3.2.RELEASE\spring-boot-2.3.2.RELEASE.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\springframework\spring-context\5.2.8.RELEASE\spring-context-5.2.8.RELEASE.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\springframework\boot\spring-boot-autoconfigure\2.3.2.RELEASE\spring-boot-autoconfigure-2.3.2.RELEASE.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\springframework\boot\spring-boot-starter-logging\2.3.2.RELEASE\spring-boot-starter-logging-2.3.2.RELEASE.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\springframework\spring-core\5.2.8.RELEASE\spring-core-5.2.8.RELEASE.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\springframework\spring-jcl\5.2.8.RELEASE\spring-jcl-5.2.8.RELEASE.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\yaml\snakeyaml\1.26\snakeyaml-1.26.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\springframework\boot\spring-boot-starter-web\2.3.2.RELEASE\spring-boot-starter-web-2.3.2.RELEASE.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\springframework\boot\spring-boot-starter-json\2.3.2.RELEASE\spring-boot-starter-json-2.3.2.RELEASE.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\com\fasterxml\jackson\core\jackson-databind\2.11.1\jackson-databind-2.11.1.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\com\fasterxml\jackson\core\jackson-annotations\2.11.1\jackson-annotations-2.11.1.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\com\fasterxml\jackson\core\jackson-core\2.11.1\jackson-core-2.11.1.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.11.1\jackson-datatype-jdk8-2.11.1.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.11.1\jackson-datatype-jsr310-2.11.1.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\com\fasterxml\jackson\module\jackson-module-parameter-names\2.11.1\jackson-module-parameter-names-2.11.1.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\springframework\boot\spring-boot-starter-tomcat\2.3.2.RELEASE\spring-boot-starter-tomcat-2.3.2.RELEASE.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\apache\tomcat\embed\tomcat-embed-core\9.0.37\tomcat-embed-core-9.0.37.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\glassfish\jakarta.el\3.0.3\jakarta.el-3.0.3.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.37\tomcat-embed-websocket-9.0.37.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\springframework\spring-web\5.2.8.RELEASE\spring-web-5.2.8.RELEASE.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\springframework\spring-beans\5.2.8.RELEASE\spring-beans-5.2.8.RELEASE.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\springframework\spring-webmvc\5.2.8.RELEASE\spring-webmvc-5.2.8.RELEASE.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\springframework\spring-aop\5.2.8.RELEASE\spring-aop-5.2.8.RELEASE.jar;D:\DevelopTools\maven\apache-maven-3.5.3\resposity\org\springframework\spring-expression\5.2.8.RELEASE\spring-expression-5.2.8.RELEASE.jar InterceptorApplication
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.2.RELEASE)
2022-04-25 21:33:06.052 INFO 19508 --- [ main] InterceptorApplication : Starting InterceptorApplication on DESKTOP-E3BKV6N with PID 19508 (H:\Dev_projects\das\java_demo\interceptor\target\classes started by LZQ in H:\Dev_projects\das\java_demo)
2022-04-25 21:33:06.054 INFO 19508 --- [ main] InterceptorApplication : No active profile set, falling back to default profiles: default
2022-04-25 21:33:06.103 WARN 19508 --- [ main] ionWarningsApplicationContextInitializer :
** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.
解决方案
在主启动类上加入包扫描的注解@ComponentScan
|