坑---- Error starting Tomcat context. Exception:org.springframework.beans.factory.BeanCreationExcepti

项目启动时报错,tomcat停止。
报错信息:

[ost-startStop-1] o.s.b.web.embedded.tomcat.TomcatStarter  : Error starting Tomcat context. Exception: 
org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 
'servletEndpointRegistrar' defined in class path resource 
[org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMv
cServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception 
is org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' 
threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with 
name 'healthEndpoint' defined in class path resource 

左思右想一直找不到问题所在,最后还是看了https://blog.csdn.net/qq_42145410/article/details/105055280 这个博主的博客才找到问题。

原因在于我的配置文件加载不成功,因为在pom文件中忽略掉了yml文件(我的项目配置文件是yml形式),最后在build中重新加入了yml的配置才能成功,感谢博主。

 <build>
        <resources>
            <resource>
                <directory>src/main/javadirectory>
                <includes>
                    <include>**/*.propertiesinclude>
                    <include>**/*.xmlinclude>
                includes>
            resource>
            <resource>
                <directory>src/main/resourcesdirectory>
                <includes>
                    <include>**/*.propertiesinclude>
                    <include>**/*.ymlinclude>
                    <include>**/*.xmlinclude>
                    <include>**/*.htmlinclude>
                    <include>**/*.jsinclude>
                    <include>**/*.cssinclude>
                    <include>**/*.svginclude>
                    <include>**/**/*.svginclude>
                    <include>**/**/*.pnginclude>
                    <include>**/*.pnginclude>
                    <include>**/*.jsoninclude>
                    <include>**/*.jpginclude>
                includes>
            resource>
            
            <resource>
                <directory>src/main/resources/jarsdirectory>
                <targetPath>BOOT-INF/jars/targetPath>
                <includes>
                    <include>**/*.jarinclude>
                includes>
            resource>
        resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-maven-pluginartifactId>
                <configuration>
                    <includeSystemScope>trueincludeSystemScope>
                configuration>
            plugin>
            <plugin>
                <artifactId>maven-compiler-pluginartifactId>
                <configuration>
                    <source>1.8source>
                    <target>1.8target>
                    <encoding>UTF-8encoding>
                    <compilerArguments>
                        <extdirs>${project.basedir}\src\main\resources\jarsextdirs>
                    compilerArguments>
                configuration>
            plugin>
        plugins>
    build>

你可能感兴趣的:(问题,java)