解决“Failed to read artifact descriptor for org.springframework.cloud:spring-cloud-st”

版权声明:转载请注明出处 https://blog.csdn.net/u010502101/article/details/82084747

今天在建立eureka微服务过程中,pom文件中一直报“Failed to read artifact descriptor for org.springframework.cloud:spring-cloud-st”的错误,并且在启动类上添加注解@EnableEurekaServer,显示不存在该注解。原因是没有正确导入eureka需要的依赖。

eureka微服务中pom文件如下

<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.lzj.springcloud</groupId>
        <artifactId>microservice-parent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>

    <artifactId>microservice-eurake1</artifactId>

    <dependencies>
        <!--eureka-server服务端 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
        </dependency>
        <!-- 修改后立即生效,热部署 -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>springloaded</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>
    </dependencies>

</project>

在依赖的父工程microservice-parent工程中已经导入了SpringCloud版本,所以在eureka微服务中的pom文件中就不需要再导入SpringCloud了,父工程导入的SpringCloud版本为

            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Dalston.SR1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

但是按上面的进行配置完后,eureka的pom文件上一直提示“Failed to read artifact descriptor for org.springframework.cloud:spring-cloud-st”的错误,并且在启动类上也没有@EnableEurekaServer注解。猜测应该是SpringCloud版本的原因,导致的eureka的依赖包的方式不正确,把eureka微服务中的pom文件改成如下就可以了,问题就完美的解决了。

<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.lzj.springcloud</groupId>
        <artifactId>microservice-parent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>

    <artifactId>microservice-eurake1</artifactId>

    <dependencies>
        <!--eureka-server服务端 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-netflix-eureka-server</artifactId>
        </dependency>
        <!-- 修改后立即生效,热部署 -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>springloaded</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>
    </dependencies>

</project>

猜你喜欢

转载自blog.csdn.net/u010502101/article/details/82084747