springCloud和springBoot的版本选择与基础配置

springcloud版本和springboot的版本选择

  <dependency>
   	  <groupId>org.springframework.bootgroupId>
         <artifactId>spring-boot-dependenciesartifactId>
         <version>2.2.4.RELEASEversion>
         <type>pomtype>
         <scope>importscope>
     dependency>
     
     <dependency>
         <groupId>org.springframework.cloudgroupId>
         <artifactId>spring-cloud-dependenciesartifactId>
         <version>Hoxton.SR1version>
         <type>pomtype>
         <scope>importscope>
     dependency>

父项目使用dependencyManagement管理依赖的导入

Maven中的dependencyManagement元素提供了一种管理依赖版本号的方式。
在dependencyManagement元素中声明所依赖的jar包的版本号等信息,那么所有子项目再次引入此依赖jar包时则无需显式的列出版本号。Maven会沿着父子层级向上寻找拥有dependencyManagement 元素的项目,然后使用它指定的版本号,通俗的来讲,子项目会寻找父项目中同一组织的版本号,这样的话子版本就不用写版本号,便于版本管理.

常用的父项目的pom.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>org.examplegroupId>
    <artifactId>Spring Cloud学习artifactId>
    <version>1.0-SNAPSHOTversion>
    <packaging>pompackaging>
    
    
    <properties>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
        <maven.compiler.source>12maven.compiler.source>
        <maven.compiler.target>12maven.compiler.target>
        <junit.version>4.12junit.version>
        <lombok.version>1.18.10lombok.version>
        <log4j.version>1.2.17log4j.version>
        <mysql.version>8.0.20mysql.version>
        <druid.version>1.1.16druid.version>
        <mybatis.spring.boot.version>2.1.1mybatis.spring.boot.version>
        <project.version>1.0-SNAPSHOTproject.version>
        <spring-boot.version>2.2.4.RELEASEspring-boot.version>
        <cloud.version>Hoxton.SR1cloud.version>
    properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-project-info-reports-pluginartifactId>
                <version>3.0.0version>
            dependency>
            
            <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>${cloud.version}version>
                <type>pomtype>
                <scope>importscope>
            dependency>
            
            
            <dependency>
                <groupId>com.alibaba.cloudgroupId>
                <artifactId>spring-cloud-alibaba-dependenciesartifactId>
                <version>2.1.0.RELEASEversion>
                <type>pomtype>
                <scope>importscope>
            dependency>
            
            <dependency>
                <groupId>mysqlgroupId>
                <artifactId>mysql-connector-javaartifactId>
                <version>${mysql.version}version>
                <scope>runtimescope>
            dependency>
            
            <dependency>
                <groupId>com.alibabagroupId>
                <artifactId>druidartifactId>
                <version>${druid.version}version>
            dependency>


            <dependency>
                <groupId>org.mybatis.spring.bootgroupId>
                <artifactId>mybatis-spring-boot-starterartifactId>
                <version>${mybatis.spring.boot.version}version>
            dependency>
            
            <dependency>
                <groupId>junitgroupId>
                <artifactId>junitartifactId>
                <version>${junit.version}version>
            dependency>
            
            <dependency>
                <groupId>log4jgroupId>
                <artifactId>log4jartifactId>
                <version>${log4j.version}version>
            dependency>
        dependencies>
    dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-maven-pluginartifactId>
                <version>2.2.4.RELEASEversion>
                <configuration>
                    <fork>truefork>
                    <addResources>trueaddResources>
                configuration>
            plugin>
        plugins>
    build>
project>

你可能感兴趣的:(springcloud)