0

当我尝试启动 SpringBoot 主应用程序时,出现以下异常。为什么我得到这个异常。

例外:

java.lang.IllegalStateException:org.springframework.cloud.config.server.config.EnvironmentRepositoryConfiguration.multipleJGitEnvironmentProperties上的错误处理条件 在 org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60) ~[spring-boot-autoconfigure-2.4.4.jar:2.4.4] 在 org.springframework.context.annotation.ConditionEvaluator。 shouldSkip(ConditionEvaluator.java:108) ~[spring-context-5.3.5.jar:5.3.5] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:193) ~[spring-context-5.3 .5.jar:5.3.5] 在 org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:153) ~[spring-context-5.3.5.jar:5.3.5] 在 org.springframework.context .annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:129) ~[spring-context-5.3.5.jar:5.3.5] 在 org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:343) ~[spring-context-5.3.5.jar:5.3 .5] 在 org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:247) ~[spring-context-5.3.5.jar:5.3.5] 在 org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors (PostProcessorRegistrationDelegate.java:311)~[spring-context-5.3.5.jar:5.3.5] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:112)~[spring-context-5.3。 5.jar:5.3.5] 在 org.springframework.context.support.AbstractApplicationContext。invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:746) ~[spring-context-5.3.5.jar:5.3.5] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564) ~[spring-context-5.3 .5.jar:5.3.5] 在 org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.4.jar:2.4.4] 在 org .springframework.boot.SpringApplication.refresh(SpringApplication.java:769) [spring-boot-2.4.4.jar:2.4.4] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring- boot-2.4.4.jar:2.4.4] 在 org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) [spring-boot-2.4.4.jar:2.4.4] 在 org.springframework.boot .SpringApplication.run(SpringApplication.java:326) [spring-boot-2.4.4.jar:2.4.4] 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1313) [spring-boot-2.4.4.jar:2.4.4] 在 org.springframework.boot.SpringApplication.run(SpringApplication.java :1302) [spring-boot-2.4.4.jar:2.4.4]

代码:

pom.xml

<project>  <!-- Removed name spaces and posted here -->
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.4.4</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.configserver.microservices</groupId>
<artifactId>spring-cloud-config-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-cloud-config-server</name>
<description>Centralized configuration server</description>
<properties>
    <java.version>1.8</java.version>
    <spring-cloud.version>2020.0.2</spring-cloud.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config</artifactId>
    </dependency>   
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </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>

application.properties
spring.application.name=spring-cloud-config-server
server.port=8888
spring.cloud.config.server.git.uri=file:///d:/git-localconfig
#spring.profiles.active =native(注意:我尝试启用此属性。但不起作用)

Spring Boot 主 java 类

@SpringBootApplication
@EnableConfigServer
public class SpringCloudConfigServerApplication {

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

}
4

1 回答 1

0

在对 pom.xml 进行如下更改后解决了

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <!-- <version>2.4.4</version> -->
        <version>2.3.3.RELEASE</version><!-- Working -->
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.configserver.microservices</groupId>
    <artifactId>spring-cloud-config-server</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>spring-cloud-config-server</name>
    <description>Centralized configuration server</description>
    <properties>
        <java.version>1.8</java.version>
        <!-- <spring-cloud.version>2020.0.2</spring-cloud.version> -->
        <spring-cloud.version>Hoxton.SR8</spring-cloud.version> <!--Working-->
    </properties>
于 2021-04-11T14:53:54.683 回答