pom文件的基本说明,为了培养对Maven的自信简单说明

<?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文件,简要介绍了一下,私服的概念。





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章