2016-10-26 18 views
5

新しいバージョンのSpringBootに切り替えると、アプリケーションを起動するときに上記のエラーメッセージが表示されます。 なぜですか?1.3.7.RELEASE - > 1.4.1.RELEASE | java.lang.NoSuchMethodError:org.springframework.boot.builder.SpringApplicationBuilder.showBanner

お祈り申し上げます スティーブン

の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

コンソール:春ブーツ1.4.1.RELEASEで作業する場合、彼らは Banner.Mode bannerModeは、どちらかのために列挙型を期待

new SpringApplicationBuilder().showBanner()

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

からそれを変更した0

@SpringBootApplication 
@ComponentScan(value = "de.xyzs.microservice") 
@EnableAspectJAutoProxy(proxyTargetClass = true) 

public class MainClass { 

    public static void main(String[] args) { 
     SpringApplication.run(MainClass.class, args); 
    } 
} 
+0

詳細を追加してください。 –

+0

例外メッセージはかなり明確です...あなたは 'NoSuchMethodError'とは何ですか? ... –

+0

"pom.xml"ファイルを追加しました。 :-) –

答えて

3

、ログ、またはオフに設定します。

例:

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 

あなたは、印刷するバナーを探している場合は、最初の1で行く、Banner.Mode.CONSOLE

新しいmainメソッドは次のようになります。

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.) 
} 

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

+0

これにどのように影響を与えることができますか?私はちょうど現在のバージョンのSpringで作業したいと思います... –

+0

あなたの主な方法がどのように見えるかを示す答えを編集しました。 SpringApplicationBuilder()の結果を変数に格納する必要はありません。単に、その処理をどのように行うかを示します。 – Bwvolleyball

+0

これは私には役に立たなかった。 – jDub9

0

クラウドの依存関係をチェックしてください。私は同じ問題を抱えていて、私のクラウドの依存関係をうまく整理するだけです。 クラウドを使用しない場合は、クラウド移行依存関係をpomから除外してください。

2

私は明示的にダミーProducer-消費者microserviceを設定しながら、私も同じ問題を取得したバージョン1.4.4

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

thx!できます! :-) –

+0

これはうまくいった。ありがとうございました! – jDub9

0

のために働くクラウドコンテキスト依存性を宣言することでこの問題を解決することができました。

以下の変更をPom.xmlに追加すると、私の問題を解決できました。

<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>