<?xml version="1.0" encoding="UTF-8"?>
<!-- 這裏聲明瞭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"><!-- 這個project標籤是pom文件的根節點,裏面聲明瞭命名空間等。以上兩項不是必須的,但是可以幫助ide對pom文件進行解析,便於我們編輯。 -->
<modelVersion>4.0.0</modelVersion><!-- 這裏的modelversion說明了pom的版本信息,對於maven2 3 只能是4.0.0 -->
<modules> <module>ymit-core</module> <module>ymit-single-starter</module> </modules><!-- modules標籤 專業術語叫聚合,其實就是把幾個工程聯合在一起,由部分功能的模塊組合成整體的軟件,這裏面就可以看出來,組合了兩個工程(或者說兩個功能模塊)。 -->
<groupId>cn.com.yusys.ymit</groupId> <artifactId>ymit-admin</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>pom</packaging> <name>ymit-admin</name><!-- 這四個必須的,專業術語叫maven座標,具體來說就是groupID是組織就是公司的網址的倒序.項目名稱。artifactid 是改軟件名字。 下邊就是版本了 ,分爲snashot就是不穩定的開發測試版,和release發佈版穩定版 name是工程名 描述就不多說了-->
<description>Yusys MockService and Interface Testing Tools</description> </project>首先貼兩張pom文件
<?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>
<artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId>
<version>1.5.2.RELEASE</version>
<relativePath />
</parent>
<!-- 這個parent專業術語叫繼承目的就是爲了簡化下邊的代碼的書寫,減去重複配置, 將多個功能都依賴的功能,我單獨都拿出來,作爲父工程,這樣,其他的工程繼承一下這個父親就好了,而且版本不會有差異,大家用的都是一樣的 -->
<groupId>cn.com.yusys.ymit</groupId> <artifactId>ymit-core</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>ymit-core</name> <url>http://www.example.com</url> <properties> <springfox.version>2.6.1</springfox.version> <undertow.version>1.4.10.Final</undertow.version> <validation-api.version>1.1.0.Final</validation-api.version> <yarn.version>v0.21.3</yarn.version> </properties><!-- 這個properties的作用就是定義常量,因爲很多可能版本什麼的會有很多相同的,我就定一個常量,下邊的使用的時候加上$就形成引用關係,可以應用這個值 -->
<dependencies> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>${springfox.version}</version> <exclusions> <exclusion> <artifactId>mapstruct</artifactId> <groupId>org.mapstruct</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> <groupId>net.java.dev.jna</groupId> <artifactId>jna</artifactId> </dependency> <dependency> <groupId>net.logstash.logback</groupId> <artifactId>logstash-logback-encoder</artifactId> <version>${logstash-logback-encoder.version}</version> <exclusions> <exclusion> <artifactId>logback-core</artifactId> <groupId>ch.qos.logback</groupId> </exclusion> <exclusion> <artifactId>logback-classic</artifactId> <groupId>ch.qos.logback</groupId> </exclusion> <exclusion> <artifactId>logback-access</artifactId> <groupId>ch.qos.logback</groupId> </exclusion> </exclusions> </dependency><!-- 這個dependecy就是依賴了,依賴裏面寫的就是上邊說的那個座標, 這是爲了引用到唯一的,別引用錯了,但是有時候,你引用我,我還引用了別人呢, 你不想引用這個別人,或者你不喜歡他版本,要用另一個版本,那就用exclusion去掉吧 -->
</dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>${maven-compiler-plugin.version}</version> <configuration> <annotationProcessorPaths> <path> <groupId>org.mapstruct</groupId> <artifactId>mapstruct-processor</artifactId> <version>${mapstruct.version}</version> </path> </annotationProcessorPaths> <compilerArguments> <extdirs>lib/</extdirs> </compilerArguments> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>${maven-resources-plugin.version}</version> <executions> <execution> <id>default-resources</id> <phase>validate</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>target/classes</outputDirectory> <useDefaultDelimiters>false</useDefaultDelimiters> <delimiters> <delimiter>#</delimiter> </delimiters> <resources> <resource> <directory>src/main/resources/</directory> <filtering>true</filtering> <includes> <include>**/*.xml</include> <include>**/*.yml</include> </includes> </resource> <resource> <directory>src/main/resources/</directory> <filtering>false</filtering> <excludes> <exclude>**/*.xml</exclude> <exclude>**/*.yml</exclude> </excludes> </resource> </resources> </configuration> </execution> </executions> </plugin> </plugins> </build><!-- 這個build就是maven的全局插件層了,意思就是,maven的功能是一部分的, 你要想用有些功能呢,就得說明,你要用這個從插件,本質上也是maven座標引用的, 還可以加上一些設置,在什麼時候用這些插件,是編譯時還是運行時等等,具體可以參考《maven實戰》 --> <!--拆分單體注-->
<!--<profile>--> <!-- Profile for tracing requests with Zipkin. --> <!-- <id>zipkin</id> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-zipkin</artifactId> </dependency> </dependencies> </profile>--> <profile> <!-- Profile for applying IDE-specific configuration. At the moment it only configures MapStruct, which you need when working with DTOs. --> <id>IDE</id> <dependencies> <dependency> <groupId>org.mapstruct</groupId> <artifactId>mapstruct-processor</artifactId> <version>${mapstruct.version}</version> </dependency> </dependencies> </profile> </profiles><!-- 這個profiles是針對不通的環境,測試環境,開發環境等 -->
</project><?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups>
<!-- pluginGroup
| Specifies a further group identifier to use for plugin lookup.
<pluginGroup>com.your.plugins</pluginGroup>
-->
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>nexus</id>
<username>dev</username>
<password>dev123</password>
</server>
<server>
<id>yusys-snapshots</id>
<username>dev</username>
<password>dev123</password>
</server>
<server>
<id>yusys-releases</id>
<username>dev</username>
<password>dev123</password>
</server>
</servers>
<!-- server配置的用戶名和密碼以及不同環境 -->
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://192.168.251.151:8081/repository/maven-public/</url>
</mirror>
</mirrors>
<!-- 攔截所有的請求,使得當maven要去下載jar包時,被攔截下來,去訪問私服。
-->
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!-- 這就是配置的開發環境測試環境和穩定版環境
-->
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
<!-- 激活當前正在使用的是哪個環境
--></settings>
這個是maven的settings.xml文件,簡要介紹了一下,私服的概念。