2017-06-20 11 views
4

私の春のブートでリクエストを別のサーバーにルーティングしようとしています。Springブート:クラスorg.springframework.cloud.netflix.zuul.ZuulConfigurationの注釈付きメソッドのイントロスペクションに失敗しました

ポンポン

<?xml version="1.0"?> 
<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/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <parent> 
     <groupId>com.company.etc.settings</groupId> 
     <artifactId>projects</artifactId> 
     <version>1.8</version> 
    </parent> 
    <groupId>com.company.gateway</groupId> 
    <artifactId>gateway</artifactId> 
    <name>gateway</name> 
    <version>0.0.1</version> 
    <packaging>jar</packaging> 
    <inceptionYear>2017</inceptionYear> 
    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <java.source.version>1.8</java.source.version> 
     <pmd.version>3.6</pmd.version> 
     <findbugs.version>3.0.3</findbugs.version> 
     <spring.boot>1.5.3.RELEASE</spring.boot> 
     <swagger.version>1.5.13</swagger.version> 
     <jacoco.version>0.7.5.201505241946</jacoco.version> 
    </properties> 
    <dependencies> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-parent</artifactId> 
      <version>${spring.boot}</version> 
      <type>pom</type> 
     </dependency> 
     <dependency> 
      <groupId>com.oracle</groupId> 
      <artifactId>ojdbc</artifactId> 
      <version>7</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-jersey</artifactId> 
      <version>${spring.boot}</version> 
      <type>pom</type> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-logging</artifactId> 
      <version>${spring.boot}</version> 
      <type>pom</type> 
     </dependency> 
     <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> 
      <version>${spring.boot}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-actuator</artifactId> 
      <version>${spring.boot}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-jdbc</artifactId> 
      <version>${spring.boot}</version> 
      <type>pom</type> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-security</artifactId> 
      <version>${spring.boot}</version> 
      <type>pom</type> 
     </dependency> 
     <dependency> 
      <groupId>io.swagger</groupId> 
      <artifactId>swagger-jaxrs</artifactId> 
      <version>${swagger.version}</version> 
     </dependency> 
     <dependency> 
      <artifactId>junit</artifactId> 
      <groupId>junit</groupId> 
      <version>4.11</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.mockito</groupId> 
      <artifactId>mockito-all</artifactId> 
      <version>1.10.19</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.easytesting</groupId> 
      <artifactId>fest-assert</artifactId> 
      <version>1.4</version> 
      <scope>test</scope> 
     </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> 

Application.properties

zuul.routes.foos.path=/r/users/** 
zuul.routes.foos.url=http://com.company.sws/c/users/ 

メインクラス

@EnableZuulProxy 
@SpringBootApplication 
@ComponentScan 
@EnableAutoConfiguration 
public class GatewayApplication { 

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

アプリケーション

2017-06-20 09:13:42.720 ERROR 15296 --- [   main] o.s.boot.SpringApplication    : Application startup failed 

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [se.telenor.bapigateway.GatewayApplication]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.cloud.netflix.zuul.ZuulConfiguration 
     at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:616) 
     at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:299) 
     at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245) 
     at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:198) 
     at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:167) 
     at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:308) 
     at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228) 
     at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:270) 
     at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) 
     at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686) 
     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524) 
     at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) 
     at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) 
     at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) 
     at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) 
     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) 
     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) 
     at se.telenor.bapigateway.GatewayApplication.main(GatewayApplication.java:20) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
     at java.lang.reflect.Method.invoke(Method.java:498) 
     at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) 
     at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) 
     at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) 
     at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) 
Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.cloud.netflix.zuul.ZuulConfiguration 
     at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:163) 
     at org.springframework.context.annotation.ConfigurationClassParser.retrieveBeanMethodMetadata(ConfigurationClassParser.java:380) 
     at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:314) 
     at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245) 
     at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:606) 
     ... 25 common frames omitted 
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/embedded/ServletRegistrationBean 
     at java.lang.Class.getDeclaredMethods0(Native Method) 
     at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) 
     at java.lang.Class.getDeclaredMethods(Class.java:1975) 
     at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:152) 
     ... 29 common frames omitted 
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.embedded.ServletRegistrationBean 
     at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
     at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
     at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94) 
     at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
を起動するとき、私はこのエラーを取得しています
+0

は、根本的な原因を参照してください: 'によって引き起こさ:java.lang.ClassNotFoundExceptionが:org.springframework.boot.context.embedded。 ServletRegistrationBean' – Jens

+0

この[質問](https://stackoverflow.com/q/20740703/1126831)で動いてください。 – ledniov

答えて

5

org.springframework.boot.context.embedded.ServletRegistrationBeanは、Springブートバージョン1.4で廃止され、その置換えであるorg.springframework.boot.web.servlet.ServletRegistrationBeanが導入されました。廃止予定のクラスは、Springブートバージョン1.5で削除されました。アプリ内またはその依存関係のいずれかに、置き換えを使用するために更新する必要があります。

2

spring-bootのためのあなたの依存関係の設定でBrixton.SR5の代わりにバージョン1.5.x使用Dalston.RELEASE

<groupId>org.springframework.cloud</groupId> 
<artifactId>spring-cloud-dependencies</artifactId> 
<version>Dalston.RELEASE</version> 
関連する問題