3,创建统一的依赖管理

概述:

温馨提示:
当前Spring Cloud Alibaba 的0.2.1RELEASE 版本基于Spring Cloud Finchley(F)
开发,故在做选择Spring boot 版本时不要使用2.1.0以及以上的版本(因为2.1.x版本
必须使用Spring Cloud Greenwich)俗称G版,请使用官方Demo中使用的2.0.6.RELEASE,以免发生意想不到的问题(比如无法注册到服务器)。


Spring Cloud Alibaba 项目都是基于Spring Cloud,而Spring Cloud项目都是基于Spring Cloud,而sprigCloud又都是基于Spring boot进行开发,并且都使用Maven做项目管理工具。在实际开发中,我们一般都会创建一个依赖管理项目作为Maven的 Parent 项目使用,这样我们可以极大的方便我们对jar 包版本进行统一管理。

<?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 http://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.0.6.RELEASE</version>
   </parent>

   <groupId>com.funtl</groupId>
   <artifactId>hello-spring-cloud-alibaba-dependencies</artifactId>
   <version>1.0.0-SNAPSHOT</version>
   <packaging>pom</packaging>

   <name>hello-spring-cloud-alibaba-dependencies</name>
   <url>http://www.funtl.com</url>
   <inceptionYear>2018-Now</inceptionYear>

   <properties>
       <!-- Environment Settings -->
       <java.version>1.8</java.version>
       <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
       <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

       <!-- Spring Settings -->
       <spring-cloud.version>Finchley.SR2</spring-cloud.version>
       <spring-cloud-alibaba.version>0.2.1.RELEASE</spring-cloud-alibaba.version>
   </properties>

   <dependencyManagement>
       <dependencies>
           <dependency>
               <groupId>org.springframework.cloud</groupId>
               <artifactId>spring-cloud-dependencies</artifactId>
               <version>${spring-cloud.version}</version>
               <type>pom</type>
               <scope>import</scope>
           </dependency>
           <dependency>
               <groupId>org.springframework.cloud</groupId>
               <artifactId>spring-cloud-alibaba-dependencies</artifactId>
               <version>${spring-cloud-alibaba.version}</version>
               <type>pom</type>
               <scope>import</scope>
           </dependency>
       </dependencies>
   </dependencyManagement>

   <build>
       <plugins>
           <!-- Compiler 插件, 设定 JDK 版本 -->
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-compiler-plugin</artifactId>
               <configuration>
                   <showWarnings>true</showWarnings>
               </configuration>
           </plugin>

           <!-- 打包 jar 文件时,配置 manifest 文件,加入 lib 包的 jar 依赖 -->
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-jar-plugin</artifactId>
               <configuration>
                   <archive>
                       <addMavenDescriptor>false</addMavenDescriptor>
                   </archive>
               </configuration>
               <executions>
                   <execution>
                       <configuration>
                           <archive>
                               <manifest>
                                   <!-- Add directory entries -->
                                   <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                                   <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                                   <addClasspath>true</addClasspath>
                               </manifest>
                           </archive>
                       </configuration>
                   </execution>
               </executions>
           </plugin>

           <!-- resource -->
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-resources-plugin</artifactId>
           </plugin>

           <!-- install -->
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-install-plugin</artifactId>
           </plugin>

           <!-- clean -->
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-clean-plugin</artifactId>
           </plugin>

           <!-- ant -->
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-antrun-plugin</artifactId>
           </plugin>

           <!-- dependency -->
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-dependency-plugin</artifactId>
           </plugin>
       </plugins>

       <pluginManagement>
           <plugins>
               <!-- Java Document Generate -->
               <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-javadoc-plugin</artifactId>
                   <executions>
                       <execution>
                           <phase>prepare-package</phase>
                           <goals>
                               <goal>jar</goal>
                           </goals>
                       </execution>
                   </executions>
               </plugin>

               <!-- YUI Compressor (CSS/JS压缩) -->
               <plugin>
                   <groupId>net.alchim31.maven</groupId>
                   <artifactId>yuicompressor-maven-plugin</artifactId>
                   <version>1.5.1</version>
                   <executions>
                       <execution>
                           <phase>prepare-package</phase>
                           <goals>
                               <goal>compress</goal>
                           </goals>
                       </execution>
                   </executions>
                   <configuration>
                       <encoding>UTF-8</encoding>
                       <jswarn>false</jswarn>
                       <nosuffix>true</nosuffix>
                       <linebreakpos>30000</linebreakpos>
                       <force>true</force>
                       <includes>
                           <include>**/*.js</include>
                           <include>**/*.css</include>
                       </includes>
                       <excludes>
                           <exclude>**/*.min.js</exclude>
                           <exclude>**/*.min.css</exclude>
                       </excludes>
                   </configuration>
               </plugin>
           </plugins>
       </pluginManagement>

       <!-- 资源文件配置 -->
       <resources>
           <resource>
               <directory>src/main/java</directory>
               <excludes>
                   <exclude>**/*.java</exclude>
               </excludes>
           </resource>
           <resource>
               <directory>src/main/resources</directory>
           </resource>
       </resources>
   </build>

   <repositories>
       <repository>
           <id>aliyun-repos</id>
           <name>Aliyun Repository</name>
           <url>http://maven.aliyun.com/nexus/content/groups/public</url>
           <releases>
               <enabled>true</enabled>
           </releases>
           <snapshots>
               <enabled>false</enabled>
           </snapshots>
       </repository>

       <repository>
           <id>sonatype-repos</id>
           <name>Sonatype Repository</name>
           <url>https://oss.sonatype.org/content/groups/public</url>
           <releases>
               <enabled>true</enabled>
           </releases>
           <snapshots>
               <enabled>false</enabled>
           </snapshots>
       </repository>
       <repository>
           <id>sonatype-repos-s</id>
           <name>Sonatype Repository</name>
           <url>https://oss.sonatype.org/content/repositories/snapshots</url>
           <releases>
               <enabled>false</enabled>
           </releases>
           <snapshots>
               <enabled>true</enabled>
           </snapshots>
       </repository>

       <repository>
           <id>spring-snapshots</id>
           <name>Spring Snapshots</name>
           <url>https://repo.spring.io/snapshot</url>
           <snapshots>
               <enabled>true</enabled>
           </snapshots>
       </repository>
       <repository>
           <id>spring-milestones</id>
           <name>Spring Milestones</name>
           <url>https://repo.spring.io/milestone</url>
           <snapshots>
               <enabled>false</enabled>
           </snapshots>
       </repository>
   </repositories>

   <pluginRepositories>
       <pluginRepository>
           <id>aliyun-repos</id>
           <name>Aliyun Repository</name>
           <url>http://maven.aliyun.com/nexus/content/groups/public</url>
           <releases>
               <enabled>true</enabled>
           </releases>
           <snapshots>
               <enabled>false</enabled>
           </snapshots>
       </pluginRepository>
   </pluginRepositories>
</project>


parent:集成了SPring boot 的Parent,标识我们是一个springboot
工程
package: pom ,表示该项目仅仅当做依赖项目,没有具体的实现代码
spring-cloud-alibaba-dependencies: 在PROPERTIES 配置中
预定义了版本号为0.2.1.RELEASE, 表示我们的Spring boot Alibaba对应的是 Spring cloud Finchley版本
build:配置了该项目所需要的各种插件
repositories: 配置项目下载依赖时的第三方库。
依赖版本说明
项目的最新版本是 0.2.1.RELEASE 和 0.1.1.RELEASE,版本 0.2.1.RELEASE 对应的是 Spring Cloud Finchley 版本,版本 0.1.1.RELEASE 对应的是 Spring Cloud Edgware 版本。
与 Spring Cloud Netflix 的区别
主要增加了 org.springframework.cloud:spring-cloud-alibaba-dependencies

https://github.com/wangjin123456/SpringCloudAlibaba/tree/master/alibaba/hello-spring-cloud-alibaba-dependencies

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,185评论 6 503
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,652评论 3 393
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 163,524评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,339评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,387评论 6 391
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,287评论 1 301
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,130评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,985评论 0 275
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,420评论 1 313
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,617评论 3 334
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,779评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,477评论 5 345
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,088评论 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,716评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,857评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,876评论 2 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,700评论 2 354

推荐阅读更多精彩内容