導(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)中的版本號多了一個點(diǎn)(.),采用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)驗(yàn),希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
SpringBoot中的@EnableAutoConfiguration注解解析
這篇文章主要介紹了SpringBoot中的@EnableAutoConfiguration注解解析,@EnableAutoConfiguration也是借助@Import的幫助,將所有符合自動配置條件的bean定義注冊到IoC容器,需要的朋友可以參考下2023-09-09
Java如何根據(jù)key值修改Hashmap中的value值
這篇文章主要介紹了Java如何根據(jù)key值修改Hashmap中的value值問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-03-03
在mybatis中使用mapper進(jìn)行if條件判斷
這篇文章主要介紹了在mybatis中使用mapper進(jìn)行if條件判斷,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-01-01

