導(dǎo)入SpringCloud依賴踩的坑及解決
導(dǎo)入SpringCloud依賴踩坑
在使用SpringCloud的時候需要導(dǎo)入spring-cloud-dependencies的依賴,
在springcloud的官網(wǎng)上面可以查到版本Version 但是在上面復(fù)制下來的版本號如下:
<dependencyManagement> ? ?<dependencies> ? ? ? <dependency> ? ? ? ? ?<groupId>org.springframework.cloud</groupId> ? ? ? ? ?<artifactId>spring-cloud-dependencies</artifactId> ? ? ? ? ?<version>Dalston SR3</version> ? ? ? ? ?<type>pom</type> ? ? ? ? ?<scope>import</scope> ? ? ? </dependency> ? ?</dependencies> </dependencyManagement>
不知道什么原因,在公司的電腦能可以正常的將依賴下載到本地庫,但是回到宿舍用自己的電腦發(fā)現(xiàn)總是下載不下來,一直都是lastUpdate
上網(wǎng)找解決方案
最后找到maven-repository中發(fā)現(xiàn)版本號如下:
<dependencyManagement> ? ?<dependencies> ? ? ? <dependency> ? ? ? ? ?<groupId>org.springframework.cloud</groupId> ? ? ? ? ?<artifactId>spring-cloud-dependencies</artifactId> ? ? ? ? ?<version>Dalston.SR3</version> ? ? ? ? ?<type>pom</type> ? ? ? ? ?<scope>import</scope> ? ? ? </dependency> ? ?</dependencies> </dependencyManagement>
相對比可以發(fā)現(xiàn), maven-repository中的版本號比springcloud官網(wǎng)中的版本號多了一個點(.),采用maven-repository中的版本號則可以將依賴下載到版本庫
所以以后找依賴還是直接取中央倉庫吧,不要在自己去官網(wǎng)復(fù)制黏貼(傻)了-->
springCloud依賴導(dǎo)入失敗

剛開始用spring Initializr創(chuàng)建spring boot項目,添加spring cloud依賴不成功
原因是:需要手動添加版本號
<?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.3.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.springcloud</groupId>
<artifactId>eureka</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>eureka</name>
<description>eureka</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>2021.0.3-SNAPSHOT</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<version>3.1.2</version>
</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>Finchley.SR1</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>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<version>3.1.2</version>
</dependency>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.SR1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
JAVA 16位ID生成工具類含16位不重復(fù)的隨機數(shù)數(shù)字+大小寫
這篇文章主要介紹了JAVA 16位ID生成工具類含16位不重復(fù)的隨機數(shù)數(shù)字+大小寫,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-02-02
一文帶你徹底了解Java8中的Lambda,函數(shù)式接口和Stream
這篇文章主要為大家詳細介紹了解Java8中的Lambda,函數(shù)式接口和Stream的用法和原理,文中的示例代碼簡潔易懂,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2023-08-08
Spring中@Repository注解的作用和用法以及和@Mapper的區(qū)別詳析
這篇文章主要給大家介紹了關(guān)于Spring中@Repository注解的作用和用法以及和@Mapper的區(qū)別的相關(guān)資料,注解的作用是標(biāo)識一個類為數(shù)據(jù)訪問對象,并由Spring框架進行實例化和管理,需要的朋友可以參考下2023-09-09

