ConfigFileApplicationListener 已弃用,只能用作 EnvironmentPostProcessor

Posted

技术标签:

【中文标题】ConfigFileApplicationListener 已弃用,只能用作 EnvironmentPostProcessor【英文标题】:ConfigFileApplicationListener is deprecated and can only be used as an EnvironmentPostProcessor 【发布时间】:2021-03-06 06:09:19 【问题描述】:

我正在尝试创建与身份验证服务集成的网关服务。 api-gateway/pom.xml

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.16.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.project</groupId>
    <artifactId>api-gateway</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>api-gateway</name>
    <description>Zuul Gateway</description>

    <properties>
        <java.version>11</java.version>
        <spring-cloud.version>Hoxton.SR9</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>$spring-cloud.version</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

对于这个项目,我在构建路径中添加了一个名为“Common”的应用程序。 在通用应用程序中有 3 个文件。 JwtAuthenticationConfig JwtTokenAuthenticationFilter JwtUsernamePasswordAuthenticationFilter 我的工作来源是this。

运行我的网关应用程序后,我面临以下错误。

19:09:27.281 [main] DEBUG org.springframework.boot.context.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: [file:/F:/eclipse-jee-2018-09-win32-x86_64/eclipse-workspace/Project/api-gateway/api-gateway/target/classes/, file:/F:/eclipse-jee-2018-09-win32-x86_64/eclipse-workspace/Project/common/common/target/classes/, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-starter-security/2.4.0/spring-boot-starter-security-2.4.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-starter/2.4.0/spring-boot-starter-2.4.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot/2.4.0/spring-boot-2.4.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.4.0/spring-boot-autoconfigure-2.4.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.4.0/spring-boot-starter-logging-2.4.0.jar, file:/C:/Users/Sreenivas/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar, file:/C:/Users/Sreenivas/.m2/repository/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar, file:/C:/Users/Sreenivas/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.13.3/log4j-to-slf4j-2.13.3.jar, file:/C:/Users/Sreenivas/.m2/repository/org/apache/logging/log4j/log4j-api/2.13.3/log4j-api-2.13.3.jar, file:/C:/Users/Sreenivas/.m2/repository/org/slf4j/jul-to-slf4j/1.7.30/jul-to-slf4j-1.7.30.jar, file:/C:/Users/Sreenivas/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar, file:/C:/Users/Sreenivas/.m2/repository/org/yaml/snakeyaml/1.27/snakeyaml-1.27.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/spring-aop/5.3.1/spring-aop-5.3.1.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/spring-beans/5.3.1/spring-beans-5.3.1.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/security/spring-security-config/5.4.1/spring-security-config-5.4.1.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/spring-context/5.3.1/spring-context-5.3.1.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/security/spring-security-web/5.4.1/spring-security-web-5.4.1.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/spring-expression/5.3.1/spring-expression-5.3.1.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-starter-web/2.4.0/spring-boot-starter-web-2.4.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.4.0/spring-boot-starter-json-2.4.0.jar, file:/C:/Users/Sreenivas/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.11.3/jackson-datatype-jdk8-2.11.3.jar, file:/C:/Users/Sreenivas/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.11.3/jackson-datatype-jsr310-2.11.3.jar, file:/C:/Users/Sreenivas/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.11.3/jackson-module-parameter-names-2.11.3.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.4.0/spring-boot-starter-tomcat-2.4.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.39/tomcat-embed-core-9.0.39.jar, file:/C:/Users/Sreenivas/.m2/repository/org/glassfish/jakarta.el/3.0.3/jakarta.el-3.0.3.jar, file:/C:/Users/Sreenivas/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.39/tomcat-embed-websocket-9.0.39.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/spring-web/5.3.1/spring-web-5.3.1.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/spring-webmvc/5.3.1/spring-webmvc-5.3.1.jar, file:/C:/Users/Sreenivas/.m2/repository/io/jsonwebtoken/jjwt/0.9.1/jjwt-0.9.1.jar, file:/C:/Users/Sreenivas/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.11.3/jackson-databind-2.11.3.jar, file:/C:/Users/Sreenivas/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.11.3/jackson-annotations-2.11.3.jar, file:/C:/Users/Sreenivas/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.11.3/jackson-core-2.11.3.jar, file:/C:/Users/Sreenivas/.m2/repository/org/projectlombok/lombok/1.18.16/lombok-1.18.16.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-starter-test/2.4.0/spring-boot-starter-test-2.4.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-test/2.4.0/spring-boot-test-2.4.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-test-autoconfigure/2.4.0/spring-boot-test-autoconfigure-2.4.0.jar, file:/C:/Users/Sreenivas/.m2/repository/com/jayway/jsonpath/json-path/2.4.0/json-path-2.4.0.jar, file:/C:/Users/Sreenivas/.m2/repository/net/minidev/json-smart/2.3/json-smart-2.3.jar, file:/C:/Users/Sreenivas/.m2/repository/net/minidev/accessors-smart/1.2/accessors-smart-1.2.jar, file:/C:/Users/Sreenivas/.m2/repository/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar, file:/C:/Users/Sreenivas/.m2/repository/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar, file:/C:/Users/Sreenivas/.m2/repository/jakarta/xml/bind/jakarta.xml.bind-api/2.3.3/jakarta.xml.bind-api-2.3.3.jar, file:/C:/Users/Sreenivas/.m2/repository/jakarta/activation/jakarta.activation-api/1.2.2/jakarta.activation-api-1.2.2.jar, file:/C:/Users/Sreenivas/.m2/repository/org/assertj/assertj-core/3.18.1/assertj-core-3.18.1.jar, file:/C:/Users/Sreenivas/.m2/repository/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar, file:/C:/Users/Sreenivas/.m2/repository/org/junit/jupiter/junit-jupiter/5.7.0/junit-jupiter-5.7.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.7.0/junit-jupiter-api-5.7.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/junit/platform/junit-platform-commons/1.7.0/junit-platform-commons-1.7.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/junit/jupiter/junit-jupiter-params/5.7.0/junit-jupiter-params-5.7.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.7.0/junit-jupiter-engine-5.7.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/junit/platform/junit-platform-engine/1.7.0/junit-platform-engine-1.7.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/mockito/mockito-core/3.6.0/mockito-core-3.6.0.jar, file:/C:/Users/Sreenivas/.m2/repository/net/bytebuddy/byte-buddy/1.10.18/byte-buddy-1.10.18.jar, file:/C:/Users/Sreenivas/.m2/repository/net/bytebuddy/byte-buddy-agent/1.10.18/byte-buddy-agent-1.10.18.jar, file:/C:/Users/Sreenivas/.m2/repository/org/objenesis/objenesis/3.1/objenesis-3.1.jar, file:/C:/Users/Sreenivas/.m2/repository/org/mockito/mockito-junit-jupiter/3.6.0/mockito-junit-jupiter-3.6.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/skyscreamer/jsonassert/1.5.0/jsonassert-1.5.0.jar, file:/C:/Users/Sreenivas/.m2/repository/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/spring-core/5.3.1/spring-core-5.3.1.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/spring-jcl/5.3.1/spring-jcl-5.3.1.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/spring-test/5.3.1/spring-test-5.3.1.jar, file:/C:/Users/Sreenivas/.m2/repository/org/xmlunit/xmlunit-core/2.7.0/xmlunit-core-2.7.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/security/spring-security-test/5.4.1/spring-security-test-5.4.1.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/security/spring-security-core/5.4.1/spring-security-core-5.4.1.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-starter-security/2.1.16.RELEASE/spring-boot-starter-security-2.1.16.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-starter/2.1.16.RELEASE/spring-boot-starter-2.1.16.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot/2.1.16.RELEASE/spring-boot-2.1.16.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.1.16.RELEASE/spring-boot-autoconfigure-2.1.16.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.1.16.RELEASE/spring-boot-starter-logging-2.1.16.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.11.2/log4j-to-slf4j-2.11.2.jar, file:/C:/Users/Sreenivas/.m2/repository/org/apache/logging/log4j/log4j-api/2.11.2/log4j-api-2.11.2.jar, file:/C:/Users/Sreenivas/.m2/repository/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar, file:/C:/Users/Sreenivas/.m2/repository/org/yaml/snakeyaml/1.23/snakeyaml-1.23.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/spring-aop/5.1.17.RELEASE/spring-aop-5.1.17.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/spring-beans/5.1.17.RELEASE/spring-beans-5.1.17.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/security/spring-security-config/5.1.11.RELEASE/spring-security-config-5.1.11.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/spring-context/5.1.17.RELEASE/spring-context-5.1.17.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/security/spring-security-web/5.1.11.RELEASE/spring-security-web-5.1.11.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/spring-expression/5.1.17.RELEASE/spring-expression-5.1.17.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/spring-web/5.1.17.RELEASE/spring-web-5.1.17.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/cloud/spring-cloud-starter-netflix-eureka-client/2.2.6.RELEASE/spring-cloud-starter-netflix-eureka-client-2.2.6.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/cloud/spring-cloud-starter/2.2.6.RELEASE/spring-cloud-starter-2.2.6.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/cloud/spring-cloud-context/2.2.6.RELEASE/spring-cloud-context-2.2.6.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/security/spring-security-crypto/5.1.11.RELEASE/spring-security-crypto-5.1.11.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/cloud/spring-cloud-commons/2.2.6.RELEASE/spring-cloud-commons-2.2.6.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/security/spring-security-rsa/1.0.9.RELEASE/spring-security-rsa-1.0.9.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/bouncycastle/bcpkix-jdk15on/1.64/bcpkix-jdk15on-1.64.jar, file:/C:/Users/Sreenivas/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.64/bcprov-jdk15on-1.64.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/cloud/spring-cloud-netflix-hystrix/2.2.6.RELEASE/spring-cloud-netflix-hystrix-2.2.6.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-starter-aop/2.1.16.RELEASE/spring-boot-starter-aop-2.1.16.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/aspectj/aspectjweaver/1.9.6/aspectjweaver-1.9.6.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/cloud/spring-cloud-netflix-eureka-client/2.2.6.RELEASE/spring-cloud-netflix-eureka-client-2.2.6.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/eureka/eureka-client/1.10.7/eureka-client-1.10.7.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/netflix-commons/netflix-eventbus/0.3.0/netflix-eventbus-0.3.0.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/netflix-commons/netflix-infix/0.3.0/netflix-infix-0.3.0.jar, file:/C:/Users/Sreenivas/.m2/repository/commons-jxpath/commons-jxpath/1.3/commons-jxpath-1.3.jar, file:/C:/Users/Sreenivas/.m2/repository/joda-time/joda-time/2.10.6/joda-time-2.10.6.jar, file:/C:/Users/Sreenivas/.m2/repository/org/antlr/antlr-runtime/3.4/antlr-runtime-3.4.jar, file:/C:/Users/Sreenivas/.m2/repository/org/antlr/stringtemplate/3.2.1/stringtemplate-3.2.1.jar, file:/C:/Users/Sreenivas/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar, file:/C:/Users/Sreenivas/.m2/repository/com/google/code/gson/gson/2.8.6/gson-2.8.6.jar, file:/C:/Users/Sreenivas/.m2/repository/org/apache/commons/commons-math/2.2/commons-math-2.2.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/archaius/archaius-core/0.7.6/archaius-core-0.7.6.jar, file:/C:/Users/Sreenivas/.m2/repository/com/google/guava/guava/29.0-jre/guava-29.0-jre.jar, file:/C:/Users/Sreenivas/.m2/repository/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar, file:/C:/Users/Sreenivas/.m2/repository/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar, file:/C:/Users/Sreenivas/.m2/repository/org/checkerframework/checker-qual/2.11.1/checker-qual-2.11.1.jar, file:/C:/Users/Sreenivas/.m2/repository/com/google/errorprone/error_prone_annotations/2.3.4/error_prone_annotations-2.3.4.jar, file:/C:/Users/Sreenivas/.m2/repository/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar, file:/C:/Users/Sreenivas/.m2/repository/javax/ws/rs/jsr311-api/1.1.1/jsr311-api-1.1.1.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/servo/servo-core/0.12.21/servo-core-0.12.21.jar, file:/C:/Users/Sreenivas/.m2/repository/com/sun/jersey/jersey-core/1.19.1/jersey-core-1.19.1.jar, file:/C:/Users/Sreenivas/.m2/repository/com/sun/jersey/jersey-client/1.19.1/jersey-client-1.19.1.jar, file:/C:/Users/Sreenivas/.m2/repository/com/sun/jersey/contribs/jersey-apache-client4/1.19.1/jersey-apache-client4-1.19.1.jar, file:/C:/Users/Sreenivas/.m2/repository/org/apache/httpcomponents/httpclient/4.5.12/httpclient-4.5.12.jar, file:/C:/Users/Sreenivas/.m2/repository/org/apache/httpcomponents/httpcore/4.4.13/httpcore-4.4.13.jar, file:/C:/Users/Sreenivas/.m2/repository/commons-codec/commons-codec/1.11/commons-codec-1.11.jar, file:/C:/Users/Sreenivas/.m2/repository/commons-configuration/commons-configuration/1.10/commons-configuration-1.10.jar, file:/C:/Users/Sreenivas/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar, file:/C:/Users/Sreenivas/.m2/repository/com/google/inject/guice/4.1.0/guice-4.1.0.jar, file:/C:/Users/Sreenivas/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar, file:/C:/Users/Sreenivas/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar, file:/C:/Users/Sreenivas/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.9.10/jackson-annotations-2.9.10.jar, file:/C:/Users/Sreenivas/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.9.10/jackson-core-2.9.10.jar, file:/C:/Users/Sreenivas/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.9.10.5/jackson-databind-2.9.10.5.jar, file:/C:/Users/Sreenivas/.m2/repository/org/codehaus/jettison/jettison/1.3.7/jettison-1.3.7.jar, file:/C:/Users/Sreenivas/.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/eureka/eureka-core/1.10.7/eureka-core-1.10.7.jar, file:/C:/Users/Sreenivas/.m2/repository/com/fasterxml/woodstox/woodstox-core/5.0.3/woodstox-core-5.0.3.jar, file:/C:/Users/Sreenivas/.m2/repository/org/codehaus/woodstox/stax2-api/3.1.4/stax2-api-3.1.4.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/cloud/spring-cloud-starter-netflix-archaius/2.2.6.RELEASE/spring-cloud-starter-netflix-archaius-2.2.6.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/cloud/spring-cloud-netflix-ribbon/2.2.6.RELEASE/spring-cloud-netflix-ribbon-2.2.6.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/cloud/spring-cloud-netflix-archaius/2.2.6.RELEASE/spring-cloud-netflix-archaius-2.2.6.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/cloud/spring-cloud-starter-netflix-ribbon/2.2.6.RELEASE/spring-cloud-starter-netflix-ribbon-2.2.6.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/ribbon/ribbon/2.3.0/ribbon-2.3.0.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/ribbon/ribbon-transport/2.3.0/ribbon-transport-2.3.0.jar, file:/C:/Users/Sreenivas/.m2/repository/io/reactivex/rxnetty-contexts/0.4.9/rxnetty-contexts-0.4.9.jar, file:/C:/Users/Sreenivas/.m2/repository/io/reactivex/rxnetty-servo/0.4.9/rxnetty-servo-0.4.9.jar, file:/C:/Users/Sreenivas/.m2/repository/io/reactivex/rxnetty/0.4.9/rxnetty-0.4.9.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/ribbon/ribbon-core/2.3.0/ribbon-core-2.3.0.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/ribbon/ribbon-httpclient/2.3.0/ribbon-httpclient-2.3.0.jar, file:/C:/Users/Sreenivas/.m2/repository/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/ribbon/ribbon-loadbalancer/2.3.0/ribbon-loadbalancer-2.3.0.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/netflix-commons/netflix-statistics/0.1.1/netflix-statistics-0.1.1.jar, file:/C:/Users/Sreenivas/.m2/repository/io/reactivex/rxjava/1.3.8/rxjava-1.3.8.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/cloud/spring-cloud-starter-loadbalancer/2.2.6.RELEASE/spring-cloud-starter-loadbalancer-2.2.6.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/cloud/spring-cloud-loadbalancer/2.2.6.RELEASE/spring-cloud-loadbalancer-2.2.6.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-starter-validation/2.1.16.RELEASE/spring-boot-starter-validation-2.1.16.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/io/projectreactor/reactor-core/3.2.19.RELEASE/reactor-core-3.2.19.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/io/projectreactor/addons/reactor-extra/3.2.4.RELEASE/reactor-extra-3.2.4.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-starter-cache/2.1.16.RELEASE/spring-boot-starter-cache-2.1.16.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/spring-context-support/5.1.17.RELEASE/spring-context-support-5.1.17.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/com/stoyanr/evictor/1.0.0/evictor-1.0.0.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/ribbon/ribbon-eureka/2.3.0/ribbon-eureka-2.3.0.jar, file:/C:/Users/Sreenivas/.m2/repository/com/thoughtworks/xstream/xstream/1.4.13/xstream-1.4.13.jar, file:/C:/Users/Sreenivas/.m2/repository/xmlpull/xmlpull/1.1.3.1/xmlpull-1.1.3.1.jar, file:/C:/Users/Sreenivas/.m2/repository/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/cloud/spring-cloud-starter-netflix-zuul/2.2.6.RELEASE/spring-cloud-starter-netflix-zuul-2.2.6.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/cloud/spring-cloud-netflix-zuul/2.2.6.RELEASE/spring-cloud-netflix-zuul-2.2.6.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/netflix-commons/netflix-commons-util/0.3.0/netflix-commons-util-0.3.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-starter-web/2.1.16.RELEASE/spring-boot-starter-web-2.1.16.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.1.16.RELEASE/spring-boot-starter-json-2.1.16.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.9.10/jackson-datatype-jdk8-2.9.10.jar, file:/C:/Users/Sreenivas/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.9.10/jackson-datatype-jsr310-2.9.10.jar, file:/C:/Users/Sreenivas/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.9.10/jackson-module-parameter-names-2.9.10.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.1.16.RELEASE/spring-boot-starter-tomcat-2.1.16.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.37/tomcat-embed-core-9.0.37.jar, file:/C:/Users/Sreenivas/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.37/tomcat-embed-el-9.0.37.jar, file:/C:/Users/Sreenivas/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.37/tomcat-embed-websocket-9.0.37.jar, file:/C:/Users/Sreenivas/.m2/repository/org/hibernate/validator/hibernate-validator/6.0.20.Final/hibernate-validator-6.0.20.Final.jar, file:/C:/Users/Sreenivas/.m2/repository/javax/validation/validation-api/2.0.1.Final/validation-api-2.0.1.Final.jar, file:/C:/Users/Sreenivas/.m2/repository/org/jboss/logging/jboss-logging/3.3.3.Final/jboss-logging-3.3.3.Final.jar, file:/C:/Users/Sreenivas/.m2/repository/com/fasterxml/classmate/1.4.0/classmate-1.4.0.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/spring-webmvc/5.1.17.RELEASE/spring-webmvc-5.1.17.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-starter-actuator/2.1.16.RELEASE/spring-boot-starter-actuator-2.1.16.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-actuator-autoconfigure/2.1.16.RELEASE/spring-boot-actuator-autoconfigure-2.1.16.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/boot/spring-boot-actuator/2.1.16.RELEASE/spring-boot-actuator-2.1.16.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/io/micrometer/micrometer-core/1.1.16/micrometer-core-1.1.16.jar, file:/C:/Users/Sreenivas/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.9/HdrHistogram-2.1.9.jar, file:/C:/Users/Sreenivas/.m2/repository/org/latencyutils/LatencyUtils/2.0.3/LatencyUtils-2.0.3.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/cloud/spring-cloud-starter-netflix-hystrix/2.2.6.RELEASE/spring-cloud-starter-netflix-hystrix-2.2.6.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/hystrix/hystrix-core/1.5.18/hystrix-core-1.5.18.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/hystrix/hystrix-serialization/1.5.18/hystrix-serialization-1.5.18.jar, file:/C:/Users/Sreenivas/.m2/repository/com/fasterxml/jackson/module/jackson-module-afterburner/2.9.10/jackson-module-afterburner-2.9.10.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/hystrix/hystrix-metrics-event-stream/1.5.18/hystrix-metrics-event-stream-1.5.18.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/hystrix/hystrix-javanica/1.5.18/hystrix-javanica-1.5.18.jar, file:/C:/Users/Sreenivas/.m2/repository/org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1.jar, file:/C:/Users/Sreenivas/.m2/repository/io/reactivex/rxjava-reactive-streams/1.2.1/rxjava-reactive-streams-1.2.1.jar, file:/C:/Users/Sreenivas/.m2/repository/org/reactivestreams/reactive-streams/1.0.3/reactive-streams-1.0.3.jar, file:/C:/Users/Sreenivas/.m2/repository/com/netflix/zuul/zuul-core/1.3.1/zuul-core-1.3.1.jar, file:/C:/Users/Sreenivas/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/spring-core/5.1.17.RELEASE/spring-core-5.1.17.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/spring-jcl/5.1.17.RELEASE/spring-jcl-5.1.17.RELEASE.jar, file:/C:/Users/Sreenivas/.m2/repository/org/springframework/security/spring-security-core/5.1.11.RELEASE/spring-security-core-5.1.11.RELEASE.jar]
19:09:27.297 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.IllegalStateException: ConfigFileApplicationListener [org.springframework.boot.context.config.ConfigFileApplicationListener] is deprecated and can only be used as an EnvironmentPostProcessor
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:198)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:203)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:196)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:170)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:148)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
    at java.util.ArrayList.forEach(ArrayList.java:1249)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:362)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:144)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:212)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:117)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:74)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:203)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:196)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:170)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:148)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
    at java.util.ArrayList.forEach(ArrayList.java:1249)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:362)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298)
    at com.project.apigateway.ApiGatewayApplication.main(ApiGatewayApplication.java:12)

帮我解决这个问题。

【问题讨论】:

【参考方案1】:

问题已解决。

其实common应用和Api-gateway应用在不同的spring版本中。

更改 common 的版本并将其正确包含在 api-gateway 应用程序中解决了我的问题。

谢谢。

【讨论】:

提醒一下:确保在 Eclipse 中刷新项目以应用更改

以上是关于ConfigFileApplicationListener 已弃用,只能用作 EnvironmentPostProcessor的主要内容,如果未能解决你的问题,请参考以下文章