spring 我的微服务项目出现了配置云配置错误

ffscu2ro  于 2023-06-21  发布在  Spring
关注(0)|答案(2)|浏览(128)

这是我的错误。

"C:\Program Files\Java\jdk-11.0.12\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.2\lib\idea_rt.jar=60965:C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.2\bin" -Dfile.encoding=UTF-8 -classpath E:\order-service\target\classes;C:\Users\imal.m2\repository\org\springframework\boot\spring-boot-starter-data-jpa\2.7.13-SNAPSHOT\spring-boot-starter-data-jpa-2.7.13-20230615.160112-33.jar;C:\Users\imal.m2\repository\org\springframework\boot\spring-boot-starter-aop\2.7.13-SNAPSHOT\spring-boot-starter-aop-2.7.13-20230615.160112-33.jar;C:\Users\imal.m2\repository\org\springframework\spring-aop\5.3.28\spring-aop-5.3.28.jar;C:\Users\imal.m2\repository\org\aspectj\aspectjweaver\1.9.7\aspectjweaver-1.9.7.jar;C:\Users\imal.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\2.7.13-SNAPSHOT\spring-boot-starter-jdbc-2.7.13-20230615.160112-33.jar;C:\Users\imal.m2\repository\com\zaxxer\HikariCP\4.0.3\HikariCP-4.0.3.jar;C:\Users\imal.m2\repository\org\springframework\spring-jdbc\5.3.28\spring-jdbc-5.3.28.jar;C:\Users\imal.m2\repository\jakarta\transaction\jakarta.transaction-api\1.3.3\jakarta.transaction-api-1.3.3.jar;C:\Users\imal.m2\repository\jakarta\persistence\jakarta.persistence-api\2.2.3\jakarta.persistence-api-2.2.3.jar;C:\Users\imal.m2\repository\org\hibernate\hibernate-core\5.6.15.Final\hibernate-core-5.6.15.Final.jar;C:\Users\imal.m2\repository\org\jboss\logging\jboss-logging\3.4.3.Final\jboss-logging-3.4.3.Final.jar;C:\Users\imal.m2\repository\net\bytebuddy\byte-buddy\1.12.23\byte-buddy-1.12.23.jar;C:\Users\imal.m2\repository\antlr\antlr\2.7.7\antlr-2.7.7.jar;C:\Users\imal.m2\repository\org\jboss\jandex\2.4.2.Final\jandex-2.4.2.Final.jar;C:\Users\imal.m2\repository\com\fasterxml\classmate\1.5.1\classmate-1.5.1.jar;C:\Users\imal.m2\repository\org\hibernate\common\hibernate-commons-annotations\5.1.2.Final\hibernate-commons-annotations-5.1.2.Final.jar;C:\Users\imal.m2\repository\org\glassfish\jaxb\jaxb-runtime\2.3.8\jaxb-runtime-2.3.8.jar;C:\Users\imal.m2\repository\org\glassfish\jaxb\txw2\2.3.8\txw2-2.3.8.jar;C:\Users\imal.m2\repository\com\sun\istack\istack-commons-runtime\3.0.12\istack-commons-runtime-3.0.12.jar;C:\Users\imal.m2\repository\com\sun\activation\jakarta.activation\1.2.2\jakarta.activation-1.2.2.jar;C:\Users\imal.m2\repository\org\springframework\data\spring-data-jpa\2.7.13-SNAPSHOT\spring-data-jpa-2.7.13-20230615.154144-41.jar;C:\Users\imal.m2\repository\org\springframework\data\spring-data-commons\2.7.13-SNAPSHOT\spring-data-commons-2.7.13-20230615.153601-40.jar;C:\Users\imal.m2\repository\org\springframework\spring-orm\5.3.28\spring-orm-5.3.28.jar;C:\Users\imal.m2\repository\org\springframework\spring-context\5.3.28\spring-context-5.3.28.jar;C:\Users\imal.m2\repository\org\springframework\spring-tx\5.3.28\spring-tx-5.3.28.jar;C:\Users\imal.m2\repository\org\springframework\spring-beans\5.3.28\spring-beans-5.3.28.jar;C:\Users\imal.m2\repository\org\slf4j\slf4j-api\1.7.36\slf4j-api-1.7.36.jar;C:\Users\imal.m2\repository\org\springframework\spring-aspects\5.3.28\spring-aspects-5.3.28.jar;C:\Users\imal.m2\repository\org\springframework\boot\spring-boot-starter-web\2.7.13-SNAPSHOT\spring-boot-starter-web-2.7.13-20230615.160112-33.jar;C:\Users\imal.m2\repository\org\springframework\boot\spring-boot-starter\2.7.13-SNAPSHOT\spring-boot-starter-2.7.13-20230615.160112-33.jar;C:\Users\imal.m2\repository\org\springframework\boot\spring-boot\2.7.13-SNAPSHOT\spring-boot-2.7.13-20230615.160112-33.jar;C:\Users\imal.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.7.13-SNAPSHOT\spring-boot-autoconfigure-2.7.13-20230615.160112-33.jar;C:\Users\imal.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.7.13-SNAPSHOT\spring-boot-starter-logging-2.7.13-20230615.160112-33.jar;C:\Users\imal.m2\repository\ch\qos\logback\logback-classic\1.2.12\logback-classic-1.2.12.jar;C:\Users\imal.m2\repository\ch\qos\logback\logback-core\1.2.12\logback-core-1.2.12.jar;C:\Users\imal.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.17.2\log4j-to-slf4j-2.17.2.jar;C:\Users\imal.m2\repository\org\apache\logging\log4j\log4j-api\2.17.2\log4j-api-2.17.2.jar;C:\Users\imal.m2\repository\org\slf4j\jul-to-slf4j\1.7.36\jul-to-slf4j-1.7.36.jar;C:\Users\imal.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\imal.m2\repository\org\yaml\snakeyaml\1.30\snakeyaml-1.30.jar;C:\Users\imal.m2\repository\org\springframework\boot\spring-boot-starter-json\2.7.13-SNAPSHOT\spring-boot-starter-json-2.7.13-20230615.160112-33.jar;C:\Users\imal.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.13.5\jackson-datatype-jdk8-2.13.5.jar;C:\Users\imal.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.13.5\jackson-datatype-jsr310-2.13.5.jar;C:\Users\imal.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.13.5\jackson-module-parameter-names-2.13.5.jar;C:\Users\imal.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\2.7.13-SNAPSHOT\spring-boot-starter-tomcat-2.7.13-20230615.160112-33.jar;C:\Users\imal.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.76\tomcat-embed-core-9.0.76.jar;C:\Users\imal.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.76\tomcat-embed-el-9.0.76.jar;C:\Users\imal.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.76\tomcat-embed-websocket-9.0.76.jar;C:\Users\imal.m2\repository\org\springframework\spring-web\5.3.28\spring-web-5.3.28.jar;C:\Users\imal.m2\repository\org\springframework\spring-webmvc\5.3.28\spring-webmvc-5.3.28.jar;C:\Users\imal.m2\repository\org\springframework\spring-expression\5.3.28\spring-expression-5.3.28.jar;C:\Users\imal.m2\repository\org\springframework\cloud\spring-cloud-starter-netflix-eureka-client\3.1.6\spring-cloud-starter-netflix-eureka-client-3.1.6.jar;C:\Users\imal.m2\repository\org\springframework\cloud\spring-cloud-starter\3.1.6\spring-cloud-starter-3.1.6.jar;C:\Users\imal.m2\repository\org\springframework\cloud\spring-cloud-context\3.1.6\spring-cloud-context-3.1.6.jar;C:\Users\imal.m2\repository\org\springframework\security\spring-security-crypto\5.7.9-SNAPSHOT\spring-security-crypto-5.7.9-20230615.115752-21.jar;C:\Users\imal.m2\repository\org\springframework\cloud\spring-cloud-commons\3.1.6\spring-cloud-commons-3.1.6.jar;C:\Users\imal.m2\repository\org\springframework\security\spring-security-rsa\1.0.11.RELEASE\spring-security-rsa-1.0.11.RELEASE.jar;C:\Users\imal.m2\repository\org\bouncycastle\bcpkix-jdk15on\1.69\bcpkix-jdk15on-1.69.jar;C:\Users\imal.m2\repository\org\bouncycastle\bcprov-jdk15on\1.69\bcprov-jdk15on-1.69.jar;C:\Users\imal.m2\repository\org\bouncycastle\bcutil-jdk15on\1.69\bcutil-jdk15on-1.69.jar;C:\Users\imal.m2\repository\org\springframework\cloud\spring-cloud-netflix-eureka-client\3.1.6\spring-cloud-netflix-eureka-client-3.1.6.jar;C:\Users\imal.m2\repository\com\netflix\eureka\eureka-client\1.10.17\eureka-client-1.10.17.jar;C:\Users\imal.m2\repository\com\netflix\netflix-commons\netflix-eventbus\0.3.0\netflix-eventbus-0.3.0.jar;C:\Users\imal.m2\repository\com\netflix\netflix-commons\netflix-infix\0.3.0\netflix-infix-0.3.0.jar;C:\Users\imal.m2\repository\commons-jxpath\commons-jxpath\1.3\commons-jxpath-1.3.jar;C:\Users\imal.m2\repository\joda-time\joda-time\2.3\joda-time-2.3.jar;C:\Users\imal.m2\repository\org\antlr\antlr-runtime\3.4\antlr-runtime-3.4.jar;C:\Users\imal.m2\repository\org\antlr\stringtemplate\3.2.1\stringtemplate-3.2.1.jar;C:\Users\imal.m2\repository\com\google\code\gson\gson\2.9.1\gson-2.9.1.jar;C:\Users\imal.m2\repository\org\apache\commons\commons-math\2.2\commons-math-2.2.jar;C:\Users\imal.m2\repository\com\thoughtworks\xstream\xstream\1.4.18\xstream-1.4.18.jar;C:\Users\imal.m2\repository\io\github\x-stream\mxparser\1.2.2\mxparser-1.2.2.jar;C:\Users\imal.m2\repository\xmlpull\xmlpull\1.1.3.1\xmlpull-1.1.3.1.jar;C:\Users\imal.m2\repository\javax\ws\rs\jsr311-api\1.1.1\jsr311-api-1.1.1.jar;C:\Users\imal.m2\repository\com\netflix\servo\servo-core\0.12.21\servo-core-0.12.21.jar;C:\Users\imal.m2\repository\com\google\guava\guava\19.0\guava-19.0.jar;C:\Users\imal.m2\repository\org\apache\httpcomponents\httpclient\4.5.14\httpclient-4.5.14.jar;C:\Users\imal.m2\repository\org\apache\httpcomponents\httpcore\4.4.16\httpcore-4.4.16.jar;C:\Users\imal.m2\repository\commons-codec\commons-codec\1.15\commons-codec-1.15.jar;C:\Users\imal.m2\repository\commons-configuration\commons-configuration\1.10\commons-configuration-1.10.jar;C:\Users\imal.m2\repository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;C:\Users\imal.m2\repository\com\google\inject\guice\4.1.0\guice-4.1.0.jar;C:\Users\imal.m2\repository\javax\inject\javax.inject\1\javax.inject-1.jar;C:\Users\imal.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.13.5\jackson-annotations-2.13.5.jar;C:\Users\imal.m2\repository\com\fasterxml\jackson\core\jackson-core\2.13.5\jackson-core-2.13.5.jar;C:\Users\imal.m2\repository\org\codehaus\jettison\jettison\1.4.0\jettison-1.4.0.jar;C:\Users\imal.m2\repository\com\netflix\eureka\eureka-core\1.10.17\eureka-core-1.10.17.jar;C:\Users\imal.m2\repository\com\fasterxml\woodstox\woodstox-core\6.2.1\woodstox-core-6.2.1.jar;C:\Users\imal.m2\repository\org\codehaus\woodstox\stax2-api\4.2.1\stax2-api-4.2.1.jar;C:\Users\imal.m2\repository\org\springframework\cloud\spring-cloud-starter-loadbalancer\3.1.6\spring-cloud-starter-loadbalancer-3.1.6.jar;C:\Users\imal.m2\repository\org\springframework\cloud\spring-cloud-loadbalancer\3.1.6\spring-cloud-loadbalancer-3.1.6.jar;C:\Users\imal.m2\repository\io\projectreactor\reactor-core\3.4.30\reactor-core-3.4.30.jar;C:\Users\imal.m2\repository\org\reactivestreams\reactive-streams\1.0.4\reactive-streams-1.0.4.jar;C:\Users\imal.m2\repository\io\projectreactor\addons\reactor-extra\3.4.10\reactor-extra-3.4.10.jar;C:\Users\imal.m2\repository\org\springframework\boot\spring-boot-starter-cache\2.7.13-SNAPSHOT\spring-boot-starter-cache-2.7.13-20230615.160112-33.jar;C:\Users\imal.m2\repository\org\springframework\spring-context-support\5.3.28\spring-context-support-5.3.28.jar;C:\Users\imal.m2\repository\com\stoyanr\evictor\1.0.0\evictor-1.0.0.jar;C:\Users\imal.m2\repository\org\springframework\cloud\spring-cloud-starter-config\3.1.7\spring-cloud-starter-config-3.1.7.jar;C:\Users\imal.m2\repository\org\springframework\cloud\spring-cloud-config-client\3.1.7\spring-cloud-config-client-3.1.7.jar;C:\Users\imal.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.13.5\jackson-databind-2.13.5.jar;C:\Users\imal.m2\repository\com\h2database\h2\2.1.214\h2-2.1.214.jar;C:\Users\imal.m2\repository\org\projectlombok\lombok\1.18.28\lombok-1.18.28.jar;C:\Users\imal.m2\repository\jakarta\xml\bind\jakarta.xml.bind-api\2.3.3\jakarta.xml.bind-api-2.3.3.jar;C:\Users\imal.m2\repository\jakarta\activation\jakarta.activation-api\1.2.2\jakarta.activation-api-1.2.2.jar;C:\Users\imal.m2\repository\org\springframework\spring-core\5.3.28\spring-core-5.3.28.jar;C:\Users\imal.m2\repository\org\springframework\spring-jcl\5.3.28\spring-jcl-5.3.28.jar com.demo.microservice.orderservice.OrderServiceApplication 10:47:08.057 [main] DEBUG org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter - Application failed to start due to an exception org.springframework.cloud.commons.ConfigDataMissingEnvironmentPostProcessor$ImportException: No spring.config.import set at org.springframework.cloud.commons.ConfigDataMissingEnvironmentPostProcessor.postProcessEnvironment(ConfigDataMissingEnvironmentPostProcessor.java:82) at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:102) at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:87) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131) at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:85) at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:66) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:120) at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:114) at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:65) at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:343) at org.springframework.boot.SpringApplication.run(SpringApplication.java:301) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) at com.demo.microservice.orderservice.OrderServiceApplication.main(OrderServiceApplication.java:21) 10:47:08.061 [main] ERROR org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter -

应用程序启动失败
产品名称:
没有定义spring.config.import属性
行动:
添加一个spring.config.import=configserver:属性设置为您的配置。如果不需要配置,则添加spring.config.import=optional:configserver:要禁用此检查,请设置spring.cloud.config.enabled=false或spring.cloud.config.import-check.enabled=false。
进程已完成,退出代码为% 1

this my application.yml

server:
  port: 9192
spring:
  datasource:
    url: jdbc:h2:mem:mydb
    username: sa
    password: password
    driverClassName: org.h2.Driver
  jpa:
    spring.jpa.database-platform: org.hibernate.dialect.H2Dialect
  h2:
    console:
      enabled: true
  application:
    name: ORDER-SERVICE
  cloud:
    config:
      uri:
        - http://localhost:9196
  • 我的依赖

4.0.0 org.springframework. Boot spring-boot-starter-parent 2.7.13-SNAPSHOT com.miscroservice.demo eureka-client 0.0.1-SNAPSHOT eureka-client Spring Boot <java.version>11</java.version><spring-cloud.version>2021.0.7</spring-cloud.version> org.springframework.boot spring-boot-starter-data-jpa org.springframework.boot spring-boot-starter-web org.springframework.cloud spring-cloud-starter-netflix-eureka-client

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

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-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>
            <configuration>
                <excludes>
                    <exclude>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                    </exclude>
                </excludes>
            </configuration>
        </plugin>
    </plugins>
</build>
<repositories>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <releases>
            <enabled>false</enabled>
        </releases>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <releases>
            <enabled>false</enabled>
        </releases>
    </pluginRepository>
</pluginRepositories>
rwqw0loc

rwqw0loc1#

错误“No spring.config.import property has been defined”表明程序试图从外部配置服务器加载配置,但属性或yml文件中未定义属性spring.config.import
解决方案是将spring.config.import添加到属性或yml文件中。请参阅Sping Boot 配置数据导入以了解更多详细信息。
如果以前的事情工作,现在你遇到了问题,这可能是由于升级了Sping Boot 的版本。您可以恢复到以前的Sping Boot 版本作为解决问题的替代方法。

vddsk6oq

vddsk6oq2#

在pom.xml中添加Spring-cloud Config,
这里是最新版本

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-config-server</artifactId>
    <version>4.0.3</version>
</dependency>

相关问题