Failed to read artifact descriptor for org.springframework.cloud:spring-cloud-starter-zuul:jar:1.3.1

在搭建分布式系统,建一个Zull微服务时,集成Zuul,在pom文件导入Zuul的依赖时,一直报错:

Failed to read artifact descriptor for org.springframework.cloud:spring-cloud-starter-zuul:jar:1.3.1.RELEASE

网上逛了很久,没有找到能解决的办法,自己死磕了很久,最终完美解决。

问题:

在pom文件中导入Zull的依赖如下:

<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.0modelVersion>
  
  <parent>
    <groupId>com.lzj.springcloudgroupId>
    <artifactId>microservice-parentartifactId>
    <version>0.0.1-SNAPSHOTversion>
  parent>
  <artifactId>microservice-zullartifactId>

    <dependencies>
        
        <dependency>
            <groupId>org.springframework.cloudgroupId>
            <artifactId>spring-cloud-starter-zuulartifactId>
        dependency>
        
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>springloadedartifactId>
        dependency>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-devtoolsartifactId>
        dependency>
    dependencies>

project>

编译一直不通过,报Failed to read artifact descriptor for org.springframework.cloud:spring-cloud-starter-zuul:jar:1.3.1的错误。

解决问题:

研究了一番,发现Zuul依赖于Eureaka,那么继续导入Eureka的依赖

    <dependencies>
        
        <dependency>
            <groupId>org.springframework.cloudgroupId>
            <artifactId>spring-cloud-starter-zuulartifactId>
        dependency>
        <dependency>
            <groupId>org.springframework.cloudgroupId>
            <artifactId>spring-cloud-starter-eurekaartifactId>
        dependency>
        
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>springloadedartifactId>
        dependency>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-devtoolsartifactId>
        dependency>
    dependencies>

发现编译还是不通过,依然报Failed to read artifact descriptor for org.springframework.cloud:spring-cloud-starter-zuul:jar:1.3.1的错误。此时简直想吐,继续死磕。既然Zuul依赖Eureka,pom文件从上向下导入依赖时,那么当导入Zuul时,Eureka还没有导入进来,所以就一直报编译错误,那么把Eureka的依赖放在前面呢,如下:

    <dependencies>
        
        <dependency>
            <groupId>org.springframework.cloudgroupId>
            <artifactId>spring-cloud-starter-eurekaartifactId>
        dependency>
        <dependency>
            <groupId>org.springframework.cloudgroupId>
            <artifactId>spring-cloud-starter-zuulartifactId>
        dependency>
        
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>springloadedartifactId>
        dependency>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-devtoolsartifactId>
        dependency>
    dependencies>

发现问题解决,竟然编译通过了,推测导入Zuul时找不到Eureka的依赖导致的。当编译通过后,再把Zull的依赖放在Eureka的前面也不会报错了,因为maven已经装载了Eureka。
哈哈……

你可能感兴趣的:(分布式/SpringCloud,Zuul,分布式)