首页天道酬勤springboot自动注入,maven与springboot

springboot自动注入,maven与springboot

张世龙 05-12 08:13 66次浏览

原因:将" application.properties "重命名为" application.yml ",没有使用就回来了。

项目不会加载application.properties配置文件! errorstartingapplicationcontext.todisplaytheconditionsreportre-runyourapplicationwith ' debug ' enabled.2021-02-270888 o.s.boot.spring application 3360 application runfailedorg.spring framework.beans.factory.beancreation exception 3360 nestedexceptionisjava.lang.illegalstateexception : failedtointrospectclass [ com.atguigu.edu service.controller.er from class loader [ sun.misc.launcher $ app class loader @ 18 B4 AAC2] atorg.spring framework.beans.factory.annotation.autowiredannotationbeanpostprocessor.determinecandidateconstors release.jar:5.2.1.release] atorg.spring framework.beans.factory.support.abstractautowirecapablebeanfactory.determineconstructorsfrombeanpostpry ng-beans-5.2.1.release.jar :5.2.1.release ] atorg.spring framework.beans.factory.support.abstractautowirecapablebeanfactory.createbeaninstance (~[ spring-bbebeabe ] atorg.spring framework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean (~[ spring-beans-] atorg.spring framework.beans.factory.support.abstractautowirecapablebeanfactory.create bean (~[ spring-beans-5 atorg.spring framework.beans.factory.support.abstract beanfactory.lambda $ doget bean $0(~[ spring-beans-5.] atorg.spring framework.beans.factory.support.defaultsingletonbeanregistry.get singleton (~[ spring-beans-5.2 ] atorg.spring framework.beans.factory.support.abstract beanfactory.doget bean (abstract beanfactory.Java 3360321 ) ) ~ [ spring-beans-5.2.1.release.jar :5.2.1.release ] atorg.spring framework.beans.factory.support .

.1.RELEASE.jar:5.2.1.RELEASE]at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]at com.atguigu.eduservice.EduApplication.main(EduApplication.java:18) [classes/:na]Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.atguigu.eduservice.controller.EduChapterController] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:477) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:318) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:265) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]... 18 common frames omittedCaused by: java.lang.NoClassDefFoundError: com/atguigu/commonutils/Rat java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_131]at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_131]at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_131]at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:459) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]... 20 common frames omittedCaused by: java.lang.ClassNotFoundException: com.atguigu.commonutils.Rat java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_131]at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_131]at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) ~[na:1.8.0_131]at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_131]... 24 common frames omittedDisconnected from the target VM, address: '127.0.0.1:10210', transport: 'socket'Process finished with exit code 1 参考:SpringBoot 项目不加载 application.properties 配置文件 - 威威超酷 - 博客园 https://www.cnblogs.com/wwct/p/12258984.html
(感谢大佬!)

yml或者properties文件没有被扫描到,需要在pom文件中<build></build>添加如下.来保证文件都能正常被扫描到并且加载成功.<!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 --><resources> <resource> <directory>src/main/java</directory> <includes> <include>qkdzdj/*.yml</include> <include>qkdzdj/*.properties</include> <include>qkdzdj/*.xml</include> </includes> <filtering>false</filtering> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>qkdzdj/*.yml</include> <include>qkdzdj/*.properties</include> <include>qkdzdj/*.xml</include> </includes> <filtering>false</filtering> </resource></resources>
Springboot是什么,spring boot实战