2017-03-29 8 views
0

私はGradleで構築されたSpringブートプロジェクトを持っています。MavenでZuulプロキシがクラッシュし、Gradleが動作している春のブート

私は簡単にできるはずだと思っていたMavenに移行する必要がありますが、私はZuul depedencyの問題、または正確にはspring-cloud-starter-zuulに遭遇しました。

私は、注釈@EnableZuulProxyそれは次のエラー生成と春ブートアプリケーションを実行すると:

2017-03-30 00:02:57.521 WARN 11380 --- [ost-startStop-1] c.n.c.sources.URLConfigurationSource  : No URLs will be polled as dynamic configuration sources. 
2017-03-30 00:02:57.521 INFO 11380 --- [ost-startStop-1] c.n.c.sources.URLConfigurationSource  : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath. 
2017-03-30 00:02:57.532 INFO 11380 --- [ost-startStop-1] c.netflix.config.DynamicPropertyFactory : DynamicPropertyFactory is initialized with configuration sources: [email protected] 
2017-03-30 00:02:57.556 ERROR 11380 --- [ost-startStop-1] o.s.b.c.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'org.springframework.cloud.netflix.zuul.ZuulConfiguration$ZuulFilterConfiguration': Unsatisfied dependency expressed through field 'filters'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'simpleHostRoutingFilter' defined in org.springframework.cloud.netflix.zuul.ZuulProxyConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilter]: Factory method 'simpleHostRoutingFilter' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/http/conn/HttpClientConnectionManager 
2017-03-30 00:02:57.588 WARN 11380 --- [   main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat 
2017-03-30 00:02:57.588 ERROR 11380 --- [   main] o.s.boot.SpringApplication    : Application startup failed 

のみがMavenの上で発生するエラーを構築し、pom.xmlファイルに問題を絞り込みますvs build.gradleは実行されます。

作業build.gradleファイルいじりの後、私はこの部分をコメントアウトするときにエラーを生成するために管理している:

buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.3.RELEASE") 
    } 
} 
apply plugin: 'org.springframework.boot' 

だから、問題は、私は私のMavenのファイルでプラグインを使用していないです?

の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>aaa</groupId> 
    <artifactId>helloZuul</artifactId> 
    <version>1.0-SNAPSHOT</version> 

    <properties> 
     <maven.compiler.source>1.8</maven.compiler.source> 
     <maven.compiler.target>1.8</maven.compiler.target> 
    </properties> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
       <version>1.4.3.RELEASE</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>repackage</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 

    <dependencies> 
     <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web --> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
      <version>1.4.3.RELEASE</version> 
     </dependency> 
     <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io --> 
     <dependency> 
      <groupId>org.apache.commons</groupId> 
      <artifactId>commons-io</artifactId> 
      <version>1.3.2</version> 
     </dependency> 
     <!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-zuul --> 
     <dependency> 
      <groupId>org.springframework.cloud</groupId> 
      <artifactId>spring-cloud-starter-zuul</artifactId> 
      <version>1.2.6.RELEASE</version> 
     </dependency> 
    </dependencies> 
</project> 

build.gradle

group 'aaa' 
version '1.0-SNAPSHOT' 

buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.3.RELEASE") 
    } 
} 

apply plugin: 'java' 
apply plugin: 'idea' 
apply plugin: 'org.springframework.boot' 
apply plugin: 'war' 

sourceCompatibility = 1.8 

jar { 
    baseName = 'gs-rest-service' 
    version = '0.1.0' 
} 

repositories { 
    mavenCentral() 
} 

dependencies { 
    testCompile group: 'junit', name: 'junit', version: '4.12' 
    compile "org.springframework.boot:spring-boot-starter-web:1.4.3.RELEASE" 
    compile group: 'org.apache.commons', name: 'commons-io', version: '1.3.2' 
    compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-zuul', version: '1.2.6.RELEASE' 
} 

どのように私は私のMavenプロジェクトを実行することができますか?または、具体的には、春のブートグラブルプラグインの目的は何ですか?

ご協力いただきますようお願い申し上げます。

答えて

0

多くの試行錯誤の後に動作するようになりました。 (同じエラーを)

の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>aaa</groupId> 
    <artifactId>client</artifactId> 
    <version>1.0-SNAPSHOT</version> 

    <properties> 
     <maven.compiler.source>1.8</maven.compiler.source> 
     <maven.compiler.target>1.8</maven.compiler.target> 
    </properties> 

    <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.4.3.RELEASE</version> 
     <relativePath/> <!-- lookup parent from repository --> 
    </parent> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
      </plugin> 
     </plugins> 
    </build> 

    <dependencies> 
     <dependency> 
      <groupId>org.springframework.cloud</groupId> 
      <artifactId>spring-cloud-starter-zuul</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-test</artifactId> 
      <scope>test</scope> 
     </dependency> 

     <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io --> 
     <dependency> 
      <groupId>org.apache.commons</groupId> 
      <artifactId>commons-io</artifactId> 
      <version>1.3.2</version> 
     </dependency> 
    </dependencies> 

    <dependencyManagement> 
     <dependencies> 
      <dependency> 
       <groupId>org.springframework.cloud</groupId> 
       <artifactId>spring-cloud-dependencies</artifactId> 
       <version>Brixton.SR5</version> 
       <type>pom</type> 
       <scope>import</scope> 
      </dependency> 
     </dependencies> 
    </dependencyManagement> 
</project> 
1

以下のように、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> 
+0

は、それを追加しましたが、それはまだ失敗し、私は私が行うことができます他に何かわからない... – Nadav96

+0

Nadav96 @、私は答えを編集しました。もう一度やり直してください –

+0

まあ、エラーなしで実行しましたが、私がapplication.ymlに設定したプロキシをマッピングしていないようです。作業中の解決策について私の答えをご覧ください:) 助けてくれてありがとうございました! – Nadav96

関連する問題