0
点赞
收藏
分享

微信扫一扫

springboot启动报错需要配置spring.main.allow-bean-definition-overriding=true

戴老师成长记录仪 2022-03-23 阅读 15
java后端

使用java -jar 启动项目jar包时,报错如下:

Description:

The bean ‘requestMappingHandlerAdapter’, defined in class path resource [org/springframework/boot/autoconfigure/webrvlet/WebMvcAutoConfigurationKaTeX parse error: Can't use function '\]' in math mode at position 32: …iguration.class\̲]̲, could not be …EnableWebConfiguration.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

但是我配置文件中已经配置了,找了很多方法也没解决,后来和同事讨论,得出结论:是找不到配置文件报的错。

我的项目是拿现有项目改的,配置文件都是yml,没有sprintboot项目默认调用的配置文件application.properties,使用idea运行项目时在运行类里增加了参数指定了调用dev,所以打成jar包后,运行时,程序不知道去调用哪个配置文件造成的报错,然后我在运行时使用-Dspring.profiles.active=dev指定调用的配置文件就可以了。

原运行语句:java -jar predeal-registration-1.5-SNAPSHOT.jar

修改后:java -Dspring.profiles.active=dev -jar predeal-registration-1.5-SNAPSHOT.jar

我项目配置文件:

idea启动时指定的配置文件:

举报

相关推荐

0 条评论