1.3.7.发布>1.4.1。发布| java。lang.NoSuchMethodError:org。springframework。靴子建设者SpringApplicationBuilder。展示横幅
如果切换到新版本的SpringBoot,则在启动应用程序时会收到上述错误消息。 为什么呢
祝福 史蒂文
pom。xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.xyz.microservice</groupId>
<artifactId>spring-boot-test</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<!--version>1.3.7.RELEASE</version-->
<version>1.4.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
堆栈跟踪:
Exception in thread "main" java.lang.NoSuchMethodError:
org.springframework.boot.builder.SpringApplicationBuilder.showBanner(Z)Lorg/springframework/boot/builder/SpringApplicationBuilder;
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:109)
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:75)...
MainClass:
@SpringBootApplication
@ComponentScan(value = "de.xyzs.microservice")
@EnableAspectJAutoProxy(proxyTargetClass = true)
public class MainClass {
public static void main(String[] args) {
SpringApplication.run(MainClass.class, args);
}
}
# 1 楼答案
在测试JWT项目的演示时,我在基于maven的项目中也遇到了同样的问题
我刚刚从依赖项中删除了该版本,如下所示-
通过执行此操作,maven依赖项解析器将采用默认支持的版本
前面我提到了版本2.1.3。明确发布导致问题的版本,然后我删除了该版本,默认情况下采用了2.0.3。发布并为我工作
问题解决了。 !!!!!!!!!!!!!!!!!
# 2 楼答案
我能够通过显式声明适用于1.4.4版的云上下文依赖关系来解决这个问题
# 3 楼答案
我在建立虚拟生产者-消费者微服务时也遇到了同样的问题
在Pom中添加以下更改。xml,能够解决我的问题
# 4 楼答案
如果使用不兼容版本的库,则会出现不同的错误。因此,在进行任何故障排除之前,请检查版本并确保使用兼容版本
您可以参考下面的链接来检查哪些版本是兼容的
http://start.spring.io/actuator/info
从一个SO答案本身获取此链接:Is there a compatibility matrix of Spring-boot and Spring-cloud?
# 5 楼答案
使用弹簧靴1.4.1时。释放,他们已经从
new SpringApplicationBuilder().showBanner()
到
new SpringApplicationBuilder().bannerMode(Banner.Mode bannerMode)
其中
Banner.Mode bannerMode
需要一个枚举:控制台、日志或关闭示例:
如果您正在寻找要打印的横幅,请使用第一个横幅
Banner.Mode.CONSOLE
新的主方法如下所示:
以下是SpringApplicationBuilder的java文档:
http://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/builder/SpringApplicationBuilder.html#bannerMode-org.springframework.boot.Banner.Mode-
下面是解释
Banner.Mode
枚举的java文档:http://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/Banner.Mode.html
# 6 楼答案
查看您的云依赖关系。我也有同样的问题,只是组织我的云依赖关系很顺利。 如果不使用云,只需从pom中排除云可传递依赖项