依赖管理

   

    Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.

 

版本统一仲裁控制

项目的pom.xml中加入

 <dependencyManagement>

  <dependencies>

   <dependency>

    <groupId>junit</groupId>

    <artifactId>junit</artifactId>

    <version>4.11</version>

    <scope>test</scope>

   </dependency>

  </dependencies>

 </dependencyManagement>

 

编译版本控制

项目的pom.xml中加入

 <properties>

  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

  <jdk.version>1.8</jdk.version>

 </properties>

 <build>

  <pluginManagement>

   <plugins>

    <plugin>

     <groupId>org.apache.maven.plugins</groupId>

     <artifactId>maven-compiler-plugin</artifactId>

     <version>3.2</version>

     <configuration>

      <source>${jdk.version}</source>

      <target>${jdk.version}</target>

      <encoding>${project.build.sourceEncoding}</encoding>

      <compilerArguments>

       <verbose/>

       <bootclasspath>${java.home}/lib/rt.jar</bootclasspath>

      </compilerArguments>

     </configuration>

    </plugin>

   </plugins>

  </pluginManagement>

 </build>

 

发布管理配置

项目的pom.xml中加入

 <distributionManagement>

  <repository>

   <id>releases</id>

   <url>http://127.0.0.1:8081/nexus/content/repositories/releases/</url>

  </repository>

  <snapshotRepository>

   <id>snapshot</id>

   <url>http://127.0.0.1:8081/nexus/content/repositories/snapshots/</url>

  </snapshotRepository>

 </distributionManagement>

 

maven settings.xml 配置

 

1、servers配置

  <server>

   <id>releases</id>

   <username>admin</username>

   <password>admin123</password>

  </server>

  <server>

   <id>snapshot</id>

   <username>admin</username>

   <password>admin123</password>

  </server>

2、mirrors配置

  <mirror>

   <id>nexus</id>

   <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>

   <mirrorOf>*</mirrorOf>

  </mirror>

3、profiles配置

  <profile>

   <id>myprofile</id>

   <repositories>

    <repository>

     <id>public</id>

     <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>

     <releases>

      <enabled>true</enabled>

     </releases>

     <snapshots>

      <enabled>true</enabled>

     </snapshots>

    </repository>

   </repositories>

   <pluginRepositories>

    <pluginRepository>

     <id>public</id>

     <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>

     <releases>

      <enabled>true</enabled>

     </releases>

     <snapshots>

      <enabled>false</enabled>

     </snapshots>

    </pluginRepository>

   </pluginRepositories>

  </profile>

4、activeProfiles配置

  <activeProfile>myprofile</activeProfile>

继续阅读  

Maven最佳实践:版本管理

 http://juvenshun.iteye.com/blog/376422

猜你喜欢

转载自abacus.iteye.com/blog/2164991