maven 基础命令,pom基本标签结构及含义

原文地址:http://www.cnblogs.com/kingfy/p/5665218.html

Maven常用命令 
1. 创建Maven的普通java项目: 
   mvn archetype:create 
   -DgroupId=packageName 
   -DartifactId=projectName  
2. 创建Maven的Web项目:   
    mvn archetype:create 
    -DgroupId=packageName    
    -DartifactId=webappName 
    -DarchetypeArtifactId=maven-archetype-webapp    
3. 清理、编译:mvn clean compile
4. 清理、测试:mvn clean test
5. 清理、打包:mvn clean package  
6. 清理、安装:mvn clean install
7. 生成eclipse项目:mvn eclipse:eclipse  
8. 生成idea项目:mvn idea:idea  
9. 编译测试的内容:mvn test-compile  
10. 只打jar包: mvn jar:jar  
11. 跳过测试:  mvn install -Dmaven.test.skip=true  
11. 指定端口:  mvn -Dmaven.tomcat.port=9090
12. 只测试而不编译,也不测试编译:mvn test -skipping compile -skipping test-compile ( -skipping 的灵活运用,当然也可以用于其他组合命令) 
13. 清除eclipse的一些系统设置: mvn eclipse:clean

通过cvs或svn下载代码到本机,然后执行mvn eclipse:eclipse生成ecllipse项目文件,然后导入到eclipse就行了;修改代码后执行mvn compile或mvn test检验,也可以下载eclipse的maven插件。

发布第三方Jar到本地库中: mvn install:install-file -DgroupId=com -DartifactId=client -Dversion=0.1.0 -Dpackaging=jar -Dfile=d:\client-0.1.0.jar。

 

【添加 jar 包到本地仓库】

mvn install:install-file 
  -DgroupId=xxx
  -DartifactId=xxx     
  -Dversion=1.0         //版本号
  -Dpackaging=jar               //类型
  -Dfile=d:\xxx-1.0.jar     //jar实际路径

添加打包插件:

复制代码
<plugin>
   <artifactId>maven-compiler-plugin</artifactId>
   <configuration>
       <source>1.6</source>
       <target>1.6</target>
       <encoding>UTF-8</encoding>
       <compilerArguments>
             <extdirs>src\main\webapp\WEB-INF\lib</extdirs>
       </compilerArguments>
    </configuration>
</plugin>
复制代码

 

【库版本选择】
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>[1.1,)</version>
</dependency>
表达式 含义
(,1.0] version<=1.0
[1.2,1.3] 1.2<=version<=1.3
[1.0,2.0) 1.0<=version<2.0
[1.5,) 1.5<=version
(,1.1),(1.1,) version!=1.1

 

【pom.xml 基本节点】
<project> 根节点
<modelversion> pom.xml 使用的对象模型版本
<groupId> 创建项目的组织或团体的唯一 Id
<artifactId> 项目唯一Id, 项目名
<packaging> 打包扩展名(JAR、WAR、EAR)
<version> 项目版本号
<name> 显示名,用于生成文档
<url> 组织站点,用于生成文档
<description> 项目描述,用于生成文档
<dependency>之<scope> 管理依赖部署

<scope> 可使用 5 个值:
compile 缺省值,用于所有阶段,随项目一起发布
provided 期望JDK、容器或使用者提供此依赖。如servlet.jar
runtime 只在运行时使用
test 只在测试时使用,不随项目发布
system 需显式提供本地jar,不在代码仓库中查找

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值