【问题标题】:EnableConfigServer cannot be resolved to a typeEnableConfigServer 无法解析为类型
【发布时间】:2020-06-14 08:35:04
【问题描述】:

我想通过添加 @EnableConfigServer 来连接我的 Spring Cloud 配置服务器,但出现 EnableConfigServer 无法解析为类型的错误。已经检查了 application.properties、名称、git 存储库路径,我也已经尝试清理项目仍然出现同样的错误。我无法查看 localhost:8888/limits-service/default。请帮助我

这是我的 pom.xml

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.samazlan.microservices</groupId>
    <artifactId>spring-cloud-config-server</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>spring-cloud-config-server</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <spring-cloud.version>Hoxton.SR1</spring-cloud.version>
    </properties>

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </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>
    </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>

        <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
    </build>


</project>

【问题讨论】:

    标签: java git eclipse spring-boot config


    【解决方案1】:

    对我来说,更改启动器依赖项后问题已解决 来自

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

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

    【讨论】:

      【解决方案2】:

      您可以尝试以in here 的身份清理您的本地 .m2 maven 缓存。

      (重命名,强制maven重新创建一个新的m2文件夹)。
      然后看看是否导入了依赖项。

      【讨论】:

      猜你喜欢
      • 2015-10-22
      • 1970-01-01
      • 2019-03-16
      • 2021-08-28
      • 2013-12-14
      • 2015-06-10
      • 2015-11-22
      • 1970-01-01
      • 2014-07-23
      相关资源
      最近更新 更多