maven 手动构建项目

maven 手动构建项目

在空目录下面:

D:\test>mvn -B archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=com.stono -DartifactId=my-app

第一次会下载一些jar包,第二次输出:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Batch mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: basedir, Value: D:\test
[INFO] Parameter: package, Value: com.stono
[INFO] Parameter: groupId, Value: com.stono
[INFO] Parameter: artifactId, Value: my-app1
[INFO] Parameter: packageName, Value: com.stono
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: D:\test\my-app1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.062 s
[INFO] Finished at: 2018-03-11T10:00:54+08:00
[INFO] Final Memory: 17M/128M
[INFO] ------------------------------------------------------------------------

会创建my-app,文件:

D:.
| pom.xml
|
\---src
+---main
| \---java
| \---com
| \---stono
| App.java
|
\---test
\---java
\---com
\---stono
AppTest.java

pom.xml和App.java文件都中规中矩;

但是pom.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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.stono</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

mvn compile 编译

mvn package 打包

mvn install 安装

mvn clean 删除

mvn clean package -U  强制更新依赖,删除那些updated文件

mvn clean package -o offline编译模式,只使用本地仓库

上一篇:【jQuery】【转】jQuery中的trigger和triggerHandler区别


下一篇:NotePad++安装 html.css.js智能提示【转】