Spring Cloud Alibaba搭建(一):依赖版本选择

一、版本选择:官方已经提供了无冲突版本,有两个查看方式

1.GitHub:

打开Spring Cloud Alibaba项目的github地址,选择wiki,再点击右侧的”版本说明

Spring Cloud Alibaba搭建(一):依赖版本选择_第1张图片
Spring Cloud Alibaba搭建(一):依赖版本选择_第2张图片

由于主要是学习作用,所以此处直接选择最新版本,实际请根据需要选择!Spring Cloud Alibaba搭建(一):依赖版本选择_第3张图片

2.spring官网

spring cloud 和 spring boot的依赖关系选择

进入官网–>选择Projects—> Spring Cloud–>learn–>选择对应版本的Reference Doc
Spring Cloud Alibaba搭建(一):依赖版本选择_第4张图片

spring cloud alibaba参考文档

Spring Cloud Alibaba搭建(一):依赖版本选择_第5张图片

二、创建空项目配置依赖

1.创建空项目,用于配置公共依赖

Spring Cloud Alibaba搭建(一):依赖版本选择_第6张图片

2.xml配置


<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>

    <groupId>top.xinchildegroupId>
    <artifactId>hotchpotchartifactId>
    <version>1.0-SNAPSHOTversion>
    <name>hotchpotchname>
    
    <packaging>pompackaging>

    <properties>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
        <java.version>1.8java.version>
        <spring.boot.version>2.6.3spring.boot.version>
        <spring.cloud.version>2021.0.1spring.cloud.version>
        <spring.cloud.alibaba.version>2021.0.1.0spring.cloud.alibaba.version>
    properties>

	
	
    <dependencyManagement>
        <dependencies>
        	
        	<dependency>
                <groupId>org.springframework.bootgroupId>
        		<artifactId>spring-boot-dependenciesartifactId>
                <version>${spring.boot.version}version>
                <type>pomtype>
                <scope>importscope>
            dependency>
            
            
            <dependency>
                <groupId>org.springframework.cloudgroupId>
                <artifactId>spring-cloud-dependenciesartifactId>
                <version>${spring.cloud.version}version>
                <type>pomtype>
                <scope>importscope>
            dependency>
            
			
            <dependency>
                <groupId>com.alibaba.cloudgroupId>
                <artifactId>spring-cloud-alibaba-dependenciesartifactId>
                <version>${spring.cloud.alibaba.version}version>
                <type>pomtype>
                <scope>importscope>
            dependency>
        dependencies>
    dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-webartifactId>
        dependency>

        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-actuatorartifactId>
        dependency>

        <dependency>
            <groupId>com.alibaba.cloudgroupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discoveryartifactId>
        dependency>
    dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-maven-pluginartifactId>
            plugin>
        plugins>
    build>
project>

注:利用 dependencyManagement 多版本继承之后,parent一般用于填写自己公司的基础依赖了(有的话)

你可能感兴趣的:(#,Spring,Cloud,spring,cloud,java)