---
title: "maven常用命令"
author: "lkf520java"
date: "2011-12-18T15:08:02Z"
tags: []
categories: ["开源软件"]
slug: "maven"
draft: false
lastmod: "2011-12-18T15:08:52Z"
id: 1315298
url: "https://lkf520java.iteye.com/blog/1315298"
---

常用命令:

mvn eclipse:eclipse maven工程生成eclipse工程命令

mvn eclipse:clean 把已生成的eclipse工程文件清理掉

mvn \[clean] eclipse:myeclipse 使用myeclipse的程序员，生成Wtp插件的Web项目

把当前工程下依赖的lib包的源代码从服务器上down下来

mvn archetype:generate 创建maven项目

mvn archetype:create -DgroupId=com.oreilly -DartifactId=my-app

mvn jetty:run 运行jetty,必须安装jetty插件

mvn jetty:debug 以debug模式运行jetty ,必须安装jetty插件

mvn clean 清空生成的文件

mvn \[clean] compile 编译工程

mvn \[clean] test 编译并运行测试用例

mvn clean deploy -Pdev -DskipTests=false 编译,打包,运行test case并把当前工程打的包发布到仓库中去,仓库配置使用本地setting.xml文件的配置

mvn clean source:jar deploy 编译,打包,运行test case并把当前工程打包成jar以及对应的源代码jar宝都发布到仓库中去

mvn -s ~/.m2/settings.xml clean package 编译打包,"-s ~/.m2/settings.xml"指定所使用的setting文件

* * *

mvn deploy:deploy-file  
\-DgroupId=com  
\-DartifactId=client  
\-Dversion=0.1.0  
\-Dpackaging=jar  
\-Dfile=d:\\client-0.1.0.jar  
\-DrepositoryId=maven-repository-inner  
\-Durl=ftp://xxxxxxx/opt/maven/repository

* * *

MAVEN手工添加第三方jar包（ojdbc14.jar）第三方jar包需要手工添加

mvn install:install-file

-Dfile=E:\\maven221\\repository\\com\\oracle\\ojdbc14\\10.2.0.2.0\\ojdbc14-10.2.0.2.0.jar

-DgroupId=com.org.common.oracle

-DartifactId=oracle

-Dversion=10.2.0.2.0

-Dpackaging=jar

-DgeneratePom=true

* * *

mvn -version/-v 显示版本信息

mvn validate 验证工程是否正确

mvn site 生成工程项目信息的网站

mvn eclipse:configure-workspace -Declipse.workspace=your/workspace/pat 配置eclipse工作空间

创建工程的命令:

mvn的交互式Interactive generate Goal创建指令：mvn archetype:generate

// Creating a simple java application  
mvn archetype:create -DgroupId=\[your project's group id] -DartifactId=\[your project's artifact id]

// Creating a webapp  
mvn archetype:create -DgroupId=\[your project's group id] -DartifactId=\[your project's artifact id] -DarchetypeArtifactId=maven-archetype-webapp

// Creating a site  
mvn archetype:create -DgroupId=\[your project's group id] -DartifactId=\[your project's artifact id] -DarchetypeArtifactId=maven-archetype-site-simple

// Creating a mojo  
mvn archetype:create -DgroupId=\[your project's group id] -DartifactId=\[your project's artifact id] -DarchetypeArtifactId=maven-archetype-mojo