1.3.7.RELEASE & # 8594; 1.4.1.RELEASE | java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.showBanner

If I switch to a new version of SpringBoot, I get the above error message when starting the application. Why is this?

Regards Stephen

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> 

Stacktrace

 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); } } 
+6
source share
6 answers

When working with Spring Boot 1.4.1.RELEASE, they changed it from

new SpringApplicationBuilder().showBanner()

to

new SpringApplicationBuilder().bannerMode(Banner.Mode bannerMode)

where Banner.Mode bannerMode expects an enumeration for: Console, Magazine or Off.

examples:

 new SpringApplicationBuilder().bannerMode(Banner.Mode.CONSOLE); //Prints banner to System.out new SpringApplicationBuilder().bannerMode(Banner.Mode.LOG); //Prints banner to the log file new SpringApplicationBuilder().bannerMode(Banner.Mode.OFF); //Disables the banner 

If you are looking for a printable banner, go to the first, Banner.Mode.CONSOLE

Your new main method will look like this:

 public static void main(String[] args){ //SpringApplicationBuilder() returns an ApplicationContext, but creating the variable is optional ApplicationContext ctx = new SpringApplicationBuilder().bannerMode(Banner.Mode.CONSOLE).run(args); //Now, if you need to do something else with the ApplicationContext, you can (such as print all the beans, etc.) } 

Here is the java document for SpringApplicationBuilder:

http://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/builder/SpringApplicationBuilder.html#bannerMode-org.springframework.boot.Banner.Mode-

And here is the java document explaining the Banner.Mode Enum:

http://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/Banner.Mode.html

+4
source

I managed to resolve this by explicitly declaring a cloud context dependency that works for version 1.4.4

  <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-context</artifactId> <version>1.1.8.RELEASE</version> </dependency> 
+4
source

I also had the same problem setting up a dummy Producer-Consumer microprocessor.

Adding the changes below to Pom.xml below solved my problem.

 <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Camden.SR6</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> 
+2
source

Test your cloud dependencies. I had the same problem and am just organizing my cloud dependencies. If you are not using a cloud, just eliminate the pom cloud transition dependencies.

0
source

I also ran into the same issue in a Maven based project when testing a demo for a JWT project.

I just removed the version from the dependency as below-

 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> </dependency> 

running this maven dependency converter accepts the default supported version.

Earlier, I explicitly mentioned version 2.1.3.RELEASE, which caused the problem, and then I deleted the version, then it took the default 2.0.3.RELEASE and worked for me.

The problem is resolved. !!!!!!!!!!!!!!!!!!

0
source

You get different errors if you use incompatible versions of libraries. Therefore, before you begin troubleshooting, check the versions and make sure that you are using compatible versions.

You can click on the link below to check which versions are compatible.

http://start.spring.io/actuator/info

Got this link from one of SO, answers itself: is there a Spring-boot and Spring-cloud compatibility matrix?

0
source

Source: https://habr.com/ru/post/1258809/


All Articles