Maven2与Artifactory配置

一、设置JDK1.5环境变量;
二、解压maven,设置Maven环境变量path = %M2_HOME%\bin;
三、在DOS窗口:
   E:\> mvn archetype:create -DgroupId=com.mvn -DartifactId=mvntest
   创建一个目录名为test的jar工程
   E:\> mvn archetype:create -DgroupId=com.mvn -DartifactId=mvntest -DarchetypeArtifactId=maven-archetype-webapp
   创建一个创建一个目录名为test的war工程
四、在DOS窗口:
   E:\> mvn eclipse:eclipse
   生成eclipse 工程文件.classpath 和.project

五、解压Artifactory,运行bin\artifactory.bat;即启动Artifactory
六、访问:http://localhost:8081/artifactory/
    用户名/密码:admin/password
七、在工程pom.xml文件加artifactory仓库配置:
      <repositories>
        <repository>
            <id>artifactory</id>
            <name>local artifactory</name>
            <url>http://localhost:8081/artifactory/repo/</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
            <id>artifactory</id>
            <name>local artifactory</name>
            <url>http://localhost:8081/artifactory/plugins-releases</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

八、在工程pom.xml文件加jar包配置:
   <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
    </dependency>
  </dependencies> 

九、mvn clean install
    maven自动下载所需的pom.xml,jar等文件到本地user\.m2\repository\
十、如果找不到junit-3.8.1.jar,则在artifactory中的deploy一个即可;

附Maven2 goal命令:
# 创建普通java项目:mvn archetype:create -DgroupId=com.codeline.commons -DartifactId=pjoName   
# 创建Web项目:mvn archetype:create -DgroupId=com.mycompany.app
-DartifactId=my-webapp
-DarchetypeArtifactId=maven-archetype-webapp   
# 编译源代码:mvn compile (或者:mvn compiler:compile)  
# 编译测试代码:mvn test-compile   
# 运行测试:mvn test   
# 产生site:mvn site   
# 打包:mvn package   
# 在本地Repository中安装jar:mvn install   
# 清除产生的项目:mvn clean   
# 生成eclipse项目:mvn eclipse:eclipse  
# 生成idea项目:mvn idea:idea  
# 组合使用goal命令,如只打包不测试:mvn -Dtest package   
# 编译测试的内容:mvn test-compile  
# 只打jar包: mvn jar:jar  
# 只测试而不编译,也不测试编译:mvn test -skipping compile -skipping test-compile (这里要特别注意 -skipping 的灵活运用,当然也可以用于其他组合命令)  
# 清除eclipse的一些系统设置:mvn eclipse:clean   
# 编译不测试: mvn clean install -DskipTests=true

猜你喜欢

转载自cgp17.iteye.com/blog/561620
今日推荐