坑---- 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/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.yml</include>
                    <include>**/*.xml</include>
                    <include>**/*.html</include>
                    <include>**/*.js</include>
                    <include>**/*.css</include>
                    <include>**/*.svg</include>
                    <include>**/**/*.svg</include>
                    <include>**/**/*.png</include>
                    <include>**/*.png</include>
                    <include>**/*.json</include>
                    <include>**/*.jpg</include>
                </includes>
            </resource>
            <!--项目打包时引入导入外部的jar包-->
            <resource>
                <directory>src/main/resources/jars</directory>
                <targetPath>BOOT-INF/jars/</targetPath>
                <includes>
                    <include>**/*.jar</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <includeSystemScope>true</includeSystemScope>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                    <compilerArguments>
                        <extdirs>${project.basedir}\src\main\resources\jars</extdirs>
                    </compilerArguments>
                </configuration>
            </plugin>
        </plugins>
    </build>
  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用\[1\]和\[2\]中提到的错误信息是"Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException." 这个错误通常是由于在启动Tomcat时,Spring框架的bean创建过程中出现了异常导致的。具体的错误信息可能会有所不同,但通常都与bean的创建有关。 这个错误的原因可能有很多种,比如配置文件错误、依赖项缺失、类路径问题等等。要解决这个问题,可以尝试以下几个步骤: 1. 检查配置文件:确保配置文件中的所有配置项都正确,并且没有拼写错误或者格式错误。 2. 检查依赖项:确保项目的所有依赖项都已正确添加,并且版本兼容。 3. 检查类路径:确保所有需要的类都在类路径中,并且没有重复的类或者冲突的类。 4. 查看详细错误信息:根据错误信息中提供的更详细的异常堆栈信息,可以更准确地定位问题所在。可能需要查看相关的日志文件或者调试信息。 总之,"Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException." 这个错误通常是由于Spring框架的bean创建过程中出现异常导致的。要解决这个问题,需要仔细检查配置文件、依赖项和类路径,并查看详细的错误信息以定位问题所在。 #### 引用[.reference_title] - *1* *3* [---- Error starting Tomcat context... Exception:org.springframework.beans.factory.BeanCreationExcepti](https://blog.csdn.net/qq_42145410/article/details/105055280)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. M](https://blog.csdn.net/DuanZeting/article/details/122046523)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值