【问题标题】:Adding Spring Cloud Consul dependencies to Spring Boot POM causes exceptions when running, after compiling在Spring Boot POM中添加Spring Cloud Consul依赖会导致运行时出现异常,编译后
【发布时间】:2016-10-18 15:02:18
【问题描述】:

我有一个有趣的问题,但无法在任何地方找到解决方案。我正在尝试将 spring cloud consul 集成到我现有的 spring boot 服务应用程序中。到目前为止,我所做的只是将 spring cloud consul 依赖项添加到我的 POM 中。我已对我的服务应用程序中的任何类进行了更改。

我最初对我的课程进行了更改,但一直收到此错误。我想也许是我在代码中更改的东西导致了它,但不……不是这样。只是将它添加到 POM 中,它就给了我这个错误。澄清一下,我可以 mvn clean compile package 成功,错误只是当我尝试运行我的 spring boot 应用程序时。

我完全按照本指南:http://cloud.spring.io/spring-cloud-consul/ 将依赖项添加到我的 POM。

这是错误:

java -jar ./target/app.jar --endpoints.restart.enabled=true --endpoints.shutdown.enabled=true --logging.config=file:./config/logback.xml
java.lang.reflect.InvocationTargetException
    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:497)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Failed to introspect annotations: class org.springframework.cloud.consul.config.ConsulConfigBootstrapConfiguration
    at org.springframework.core.annotation.AnnotatedElementUtils.process(AnnotatedElementUtils.java:166)
    at org.springframework.core.annotation.AnnotatedElementUtils.isAnnotated(AnnotatedElementUtils.java:73)
    at org.springframework.core.type.StandardAnnotationMetadata.isAnnotated(StandardAnnotationMetadata.java:102)
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:74)
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:64)
    at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:140)
    at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:127)
    at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.register(AnnotatedBeanDefinitionReader.java:122)
    at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:159)
    at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:135)
    at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:127)
    at org.springframework.boot.SpringApplication.load(SpringApplication.java:615)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:139)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:125)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:75)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:1)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128)
    at org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:100)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:59)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:285)
    at com.idanalytics.service.ServiceApplication.main(ServiceApplication.java:41)
    ... 6 more
Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
    at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724)
    at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531)
    at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
    at java.lang.Class.createAnnotationData(Class.java:3521)
    at java.lang.Class.annotationData(Class.java:3510)
    at java.lang.Class.getAnnotations(Class.java:3446)
    at org.springframework.core.annotation.AnnotatedElementUtils.doProcess(AnnotatedElementUtils.java:192)
    at org.springframework.core.annotation.AnnotatedElementUtils.doProcess(AnnotatedElementUtils.java:209)
    at org.springframework.core.annotation.AnnotatedElementUtils.process(AnnotatedElementUtils.java:162)
    ... 28 more

关于可能是什么问题的任何想法?我没有添加任何新的注释。当我从我的 POM 文件中删除 consul 依赖项时,该应用程序运行良好。

编辑:这里是依赖树

[INFO] com.internal:test-service:jar:1.0.0-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter:jar:1.2.3.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot:jar:1.2.3.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-autoconfigure:jar:1.2.3.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-logging:jar:1.2.3.RELEASE:compile
[INFO] |  |  +- org.slf4j:jcl-over-slf4j:jar:1.7.11:compile
[INFO] |  |  |  \- org.slf4j:slf4j-api:jar:1.7.11:compile
[INFO] |  |  +- org.slf4j:jul-to-slf4j:jar:1.7.11:compile
[INFO] |  |  +- org.slf4j:log4j-over-slf4j:jar:1.7.11:compile
[INFO] |  |  \- ch.qos.logback:logback-classic:jar:1.1.3:compile
[INFO] |  |     \- ch.qos.logback:logback-core:jar:1.1.3:compile
[INFO] |  +- org.springframework:spring-core:jar:4.1.6.RELEASE:compile
[INFO] |  \- org.yaml:snakeyaml:jar:1.14:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.2.3.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.2.3.RELEASE:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.0.20:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.0.20:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-logging-juli:jar:8.0.20:compile
[INFO] |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.0.20:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.4.5:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.4.5:compile
[INFO] |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.4.5:compile
[INFO] |  +- org.hibernate:hibernate-validator:jar:5.1.3.Final:compile
[INFO] |  |  +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.1.3.GA:compile
[INFO] |  |  \- com.fasterxml:classmate:jar:1.0.0:compile
[INFO] |  +- org.springframework:spring-web:jar:4.1.6.RELEASE:compile
[INFO] |  \- org.springframework:spring-webmvc:jar:4.1.6.RELEASE:compile
[INFO] |     \- org.springframework:spring-expression:jar:4.1.6.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:1.2.3.RELEASE:compile
[INFO] |  \- org.springframework.boot:spring-boot-actuator:jar:1.2.3.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-integration:jar:1.2.3.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-aop:jar:1.2.3.RELEASE:compile
[INFO] |  |  +- org.aspectj:aspectjrt:jar:1.8.5:compile
[INFO] |  |  \- org.aspectj:aspectjweaver:jar:1.8.5:compile
[INFO] |  +- org.springframework:spring-messaging:jar:4.1.6.RELEASE:compile
[INFO] |  +- org.springframework:spring-tx:jar:4.1.6.RELEASE:compile
[INFO] |  +- org.springframework.integration:spring-integration-core:jar:4.1.2.RELEASE:compile
[INFO] |  |  +- org.projectreactor:reactor-core:jar:1.1.6.RELEASE:compile
[INFO] |  |  |  +- com.goldmansachs:gs-collections:jar:5.1.0:compile
[INFO] |  |  |  |  \- com.goldmansachs:gs-collections-api:jar:5.1.0:compile
[INFO] |  |  |  +- com.lmax:disruptor:jar:3.2.1:compile
[INFO] |  |  |  \- io.gatling:jsr166e:jar:1.0:compile
[INFO] |  |  \- org.springframework.retry:spring-retry:jar:1.1.1.RELEASE:compile
[INFO] |  +- org.springframework.integration:spring-integration-file:jar:4.1.2.RELEASE:compile
[INFO] |  |  \- commons-io:commons-io:jar:2.4:compile
[INFO] |  +- org.springframework.integration:spring-integration-http:jar:4.1.2.RELEASE:compile
[INFO] |  +- org.springframework.integration:spring-integration-ip:jar:4.1.2.RELEASE:compile
[INFO] |  \- org.springframework.integration:spring-integration-stream:jar:4.1.2.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.2.3.RELEASE:compile
[INFO] |  +- org.springframework:spring-jdbc:jar:4.1.6.RELEASE:compile
[INFO] |  \- org.apache.tomcat:tomcat-jdbc:jar:8.0.20:compile
[INFO] |     \- org.apache.tomcat:tomcat-juli:jar:8.0.20:compile
[INFO] +- org.springframework.cloud:spring-cloud-starter-consul-all:jar:1.0.1.RELEASE:compile
[INFO] |  +- org.springframework.cloud:spring-cloud-starter-consul-config:jar:1.0.1.RELEASE:compile
[INFO] |  |  +- org.springframework.cloud:spring-cloud-starter-consul:jar:1.0.1.RELEASE:compile
[INFO] |  |  |  +- org.springframework.cloud:spring-cloud-commons:jar:1.1.0.RELEASE:compile
[INFO] |  |  |  +- org.springframework.cloud:spring-cloud-consul-core:jar:1.0.1.RELEASE:compile
[INFO] |  |  |  +- com.ecwid.consul:consul-api:jar:1.1.10:compile
[INFO] |  |  |  \- com.google.code.gson:gson:jar:2.3.1:compile
[INFO] |  |  +- org.springframework.cloud:spring-cloud-consul-config:jar:1.0.1.RELEASE:compile
[INFO] |  |  \- org.springframework.cloud:spring-cloud-context:jar:1.1.0.RELEASE:compile
[INFO] |  \- org.springframework.cloud:spring-cloud-starter-consul-discovery:jar:1.0.1.RELEASE:compile
[INFO] |     +- org.springframework.cloud:spring-cloud-consul-discovery:jar:1.0.1.RELEASE:compile
[INFO] |     +- org.springframework.cloud:spring-cloud-netflix-core:jar:1.1.1.RELEASE:compile
[INFO] |     +- org.springframework.cloud:spring-cloud-starter-ribbon:jar:1.1.1.RELEASE:compile
[INFO] |     |  +- org.springframework.cloud:spring-cloud-starter:jar:1.1.0.RELEASE:compile
[INFO] |     |  |  \- org.springframework.security:spring-security-rsa:jar:1.0.1.RELEASE:compile
[INFO] |     |  |     \- org.bouncycastle:bcpkix-jdk15on:jar:1.47:compile
[INFO] |     |  |        \- org.bouncycastle:bcprov-jdk15on:jar:1.47:compile
[INFO] |     |  +- org.springframework.cloud:spring-cloud-starter-archaius:jar:1.1.1.RELEASE:compile
[INFO] |     |  |  +- com.netflix.archaius:archaius-core:jar:0.7.4:compile
[INFO] |     |  |  |  \- com.google.code.findbugs:jsr305:jar:3.0.1:runtime
[INFO] |     |  |  +- commons-configuration:commons-configuration:jar:1.8:compile
[INFO] |     |  |  |  \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] |     |  |  \- com.google.guava:guava:jar:18.0:compile
[INFO] |     |  +- com.netflix.ribbon:ribbon:jar:2.2.0:compile
[INFO] |     |  |  +- com.netflix.ribbon:ribbon-transport:jar:2.2.0:runtime
[INFO] |     |  |  |  +- io.reactivex:rxnetty-contexts:jar:0.4.9:runtime
[INFO] |     |  |  |  \- io.reactivex:rxnetty-servo:jar:0.4.9:runtime
[INFO] |     |  |  +- com.netflix.hystrix:hystrix-core:jar:1.5.3:runtime
[INFO] |     |  |  |  \- org.hdrhistogram:HdrHistogram:jar:2.1.7:runtime
[INFO] |     |  |  +- javax.inject:javax.inject:jar:1:runtime
[INFO] |     |  |  \- io.reactivex:rxnetty:jar:0.4.9:runtime
[INFO] |     |  |     +- io.netty:netty-codec-http:jar:4.0.27.Final:runtime
[INFO] |     |  |     |  +- io.netty:netty-codec:jar:4.0.27.Final:runtime
[INFO] |     |  |     |  \- io.netty:netty-handler:jar:4.0.27.Final:runtime
[INFO] |     |  |     \- io.netty:netty-transport-native-epoll:jar:4.0.27.Final:runtime
[INFO] |     |  |        +- io.netty:netty-common:jar:4.0.27.Final:runtime
[INFO] |     |  |        +- io.netty:netty-buffer:jar:4.0.27.Final:runtime
[INFO] |     |  |        \- io.netty:netty-transport:jar:4.0.27.Final:runtime
[INFO] |     |  +- com.netflix.ribbon:ribbon-core:jar:2.2.0:compile
[INFO] |     |  |  \- commons-lang:commons-lang:jar:2.6:compile
[INFO] |     |  +- com.netflix.ribbon:ribbon-httpclient:jar:2.2.0:compile
[INFO] |     |  |  +- commons-collections:commons-collections:jar:3.2.1:runtime
[INFO] |     |  |  +- com.sun.jersey.contribs:jersey-apache-client4:jar:1.19.1:runtime
[INFO] |     |  |  +- com.netflix.servo:servo-core:jar:0.10.1:runtime
[INFO] |     |  |  |  \- com.netflix.servo:servo-internal:jar:0.10.1:runtime
[INFO] |     |  |  \- com.netflix.netflix-commons:netflix-commons-util:jar:0.1.1:runtime
[INFO] |     |  +- com.netflix.ribbon:ribbon-loadbalancer:jar:2.2.0:compile
[INFO] |     |  |  \- com.netflix.netflix-commons:netflix-statistics:jar:0.1.1:runtime
[INFO] |     |  \- io.reactivex:rxjava:jar:1.1.5:compile
[INFO] |     \- joda-time:joda-time:jar:2.5:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.6:compile
[INFO] +- org.springframework.cloud:spring-cloud-config-client:jar:1.0.0.RELEASE:compile
[INFO] |  \- org.springframework.security:spring-security-crypto:jar:3.2.7.RELEASE:compile
[INFO] +- com.internal:rest-utility:jar:1.0.3:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.3.2:compile
[INFO] |  +- org.apache.httpcomponents:httpcore:jar:4.4.1:compile
[INFO] |  \- commons-codec:commons-codec:jar:1.6:compile
[INFO] +- org.springframework:spring-jms:jar:4.1.6.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:4.1.6.RELEASE:compile
[INFO] |  |  \- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  +- org.springframework:spring-beans:jar:4.1.6.RELEASE:compile
[INFO] |  \- org.springframework:spring-context:jar:4.1.6.RELEASE:compile
[INFO] +- org.springframework.integration:spring-integration-jms:jar:4.1.2.RELEASE:compile
[INFO] +- com.swiftmq:springsupport:jar:9.0.0:compile
[INFO] +- javax.jms:jms-api:jar:1.1-rev-1:compile
[INFO] +- com.swiftmq:swiftmq:jar:9.0.0:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.2.3.RELEASE:test
[INFO] |  +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] |  |  \- org.objenesis:objenesis:jar:2.1:test
[INFO] |  +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] |  +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] |  \- org.springframework:spring-test:jar:4.1.6.RELEASE:test
[INFO] +- com.internal:keystore-client:jar:2.46.0:compile
[INFO] |  +- com.sun.jersey:jersey-client:jar:1.19.1:compile
[INFO] |  |  \- com.sun.jersey:jersey-core:jar:1.19.1:compile
[INFO] |  |     \- javax.ws.rs:jsr311-api:jar:1.1.1:compile
[INFO] |  +- com.sun.jersey:jersey-json:jar:1.7:compile
[INFO] |  |  +- org.codehaus.jettison:jettison:jar:1.1:compile
[INFO] |  |  |  \- stax:stax-api:jar:1.0.1:compile
[INFO] |  |  +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
[INFO] |  |  |  \- javax.xml.bind:jaxb-api:jar:2.2.2:compile
[INFO] |  |  |     +- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] |  |  |     \- javax.activation:activation:jar:1.1:compile
[INFO] |  |  +- org.codehaus.jackson:jackson-core-asl:jar:1.7.1:compile
[INFO] |  |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.7.1:compile
[INFO] |  |  +- org.codehaus.jackson:jackson-jaxrs:jar:1.7.1:compile
[INFO] |  |  \- org.codehaus.jackson:jackson-xc:jar:1.7.1:compile
[INFO] |  +- net.iharder:base64:jar:2.3.8:compile
[INFO] |  +- commons-pool:commons-pool:jar:1.6:compile
[INFO] |  \- log4j:log4j:jar:1.2.17:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] \- org.mockito:mockito-all:jar:1.10.19:test

编辑:我将使用我的 maven 插件指定的版本更改为 1.3.5,现在出现不同的错误。这是我的 POM:

<?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>
    <parent>
        <groupId>com.internal</groupId>
        <artifactId>service-parent</artifactId>
        <version>1.0.4</version>
    </parent>
    <artifactId>testSVC</artifactId>
    <groupId>com.internal</groupId>
    <version>1.0.0-SNAPSHOT</version>
    <name>Test Service</name>
    <description>My first service</description>
    <properties>
        <main.basedir>${basedir}/../..</main.basedir>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</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-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-integration</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-consul-all</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
            <!-- <scope>runtime</scope> -->
        </dependency>        
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-client</artifactId>
            <version>${spring-cloud-config-ga}</version>
        </dependency>

        <dependency>
            <groupId>com.internal</groupId>
            <artifactId>rest-utility</artifactId>
            <version>[1.0.0,1.0.99)</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.3.2</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jms</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-jms</artifactId>
        </dependency>
        <dependency>
            <groupId>com.swiftmq</groupId>
            <artifactId>springsupport</artifactId>
            <version>${swiftmq-version}</version>
        </dependency>
        <dependency>
            <groupId>javax.jms</groupId>
            <artifactId>jms-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.swiftmq</groupId>
            <artifactId>swiftmq</artifactId>
            <version>${swiftmq-version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>

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

    </dependencies>

     <build>
          <plugins>
               <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>1.3.5.RELEASE</version>
               </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptor>src/assembly/bin.xml</descriptor>
                    <finalName>testSVC</finalName>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
          </plugins>
     </build>

     <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-consul-dependencies</artifactId>
                <version>1.0.1.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

</project>

新错误:

Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:62)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
    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:497)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:54)
    ... 1 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/Banner$Mode
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:121)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:84)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:1)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128)
    at org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:100)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:59)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:285)
    at com.idanalytics.service.ServiceApplication.main(ServiceApplication.java:38)
    ... 6 more
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.Banner$Mode
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at org.springframework.boot.loader.LaunchedURLClassLoader.doLoadClass(LaunchedURLClassLoader.java:178)
    at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:142)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

【问题讨论】:

    标签: java spring spring-boot consul


    【解决方案1】:

    您是否混合了两个不同版本的 Spring?您可以在此处包含mvn dependency:tree 的输出吗?

    更新

    根据mvn dependency:tree 的输出,我可以看到添加依赖项org.springframework.cloud:spring-cloud-starter-consul-all:1.0.1.RELEASE 通常取决于Spring Boot 1.3.5.RELEASE,但您包含的是较旧的Spring在您的 POM 中启动 1.2.3.RELEASE 版本。

    您能否更新您的 POM 以使用一致的 1.3.5.RELEASE 版本的 Spring Boot?如果可能,请尝试在您的 POM 中删除 Spring Boot 和 Spring Framework 的任何显式依赖声明,并让 spring-cloud-starter-consul-all 为您包含它们。

    【讨论】:

      猜你喜欢
      • 2015-11-04
      • 2019-02-09
      • 2019-08-07
      • 2021-07-24
      • 1970-01-01
      • 2018-10-09
      • 2015-12-28
      • 1970-01-01
      • 2018-02-14
      相关资源
      最近更新 更多