Maven的第一个小程序
这里是介绍关于maven的第一个小程序
关于maven的安装 : Install Maven in your computer
先看看目录结构:
这是本来的项目目录结构,由于maven有自己的目录结构,所以,下面的是加入maven元素后的目录结构:
即:
pom.xml文件要和src目录在同一级
在src目录下面,分别为main目录和test目录
在main目录下面存放项目中的模块类,如这里的com.b510.maven.hello.Hello.java
在test目录下面存放项目模块的测试类,如这里的com.b510.maven.hello.test.HelloTest.java
NOTE:
你所看到的有红色X标示错误提示,这是在Eclipse中的提示,这个可以不用理会。
接下来才是关键:
/maven_project/pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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.b510.maven.hello</groupId>
<artifactId>hello-first</artifactId>
<version>SNAPSHOT-0.0.1</version> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
pom.xml文件,是project object manager的首字母缩写。即项目对象管理。
在pom.xml文件中,对于我们写的com.b510.maven.hello.Hello.java类,他的groupId = com.b510.maven.hello, artifactId = hello-first, version = SNAPSHOT-0.0.1
而我们的测试类,所依赖的包为junit,它属于test域。
下面是Hello类和HelloTest类
/maven_project/src/com/b510/maven/hello/Hello.java
/**
*
*/
package com.b510.maven.hello; /**
* @author Hongten
* @created 2014-7-5
*/
public class Hello { public static void main(String[] args) {
System.out.println("This is a test message!");
String str = new Hello().sayHello("Hongten", 20);
System.out.println(str);
} public String sayHello(String name, int age){
return "I'm " + name + ", I'm " + age + ", Hello";
}
}
/maven_project/src/com/b510/maven/hello/test/HelloTest.java
/**
*
*/
package com.b510.maven.hello.test; import static org.junit.Assert.*; import org.junit.Test; import com.b510.maven.hello.Hello; /**
* @author Hongten
* @created 2014-7-5
*/
public class HelloTest { @Test
public void testSayHello() {
Hello hello = new Hello();
assertEquals(hello.sayHello("Hongten", 20), "I'm Hongten, I'm 20, Hello");
} }
两个类都是很简单的类。
现在我们启动windows的控制台。即运行--> cmd,或Ctrl+R --> cmd
进入到项目的根目录:D:\Development\workspace\maven_project
1.运行命令:mvn compile
由于我们本地仓库中没有编译所需要的资源,所有,maven会到远程仓库中去获取资源到本地
下面是控制台运行效果:这里只是截取了部分log
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-p
arameter-documenter/2.0.6/maven-plugin-parameter-documenter-2.0.6.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-pa
rameter-documenter/2.0.6/maven-plugin-parameter-documenter-2.0.6.pom (2 KB at 3.
8 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/reporting/mave
n-reporting-api/2.0.6/maven-reporting-api-2.0.6.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/reporting/maven
-reporting-api/2.0.6/maven-reporting-api-2.0.6.pom (2 KB at 3.8 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/reporting/mave
n-reporting/2.0.6/maven-reporting-2.0.6.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/reporting/maven
-reporting/2.0.6/maven-reporting-2.0.6.pom (2 KB at 3.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-si
nk-api/1.0-alpha-7/doxia-sink-api-1.0-alpha-7.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-sin
k-api/1.0-alpha-7/doxia-sink-api-1.0-alpha-7.pom (424 B at 0.9 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia/1.
0-alpha-7/doxia-1.0-alpha-7.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia/1.0
-alpha-7/doxia-1.0-alpha-7.pom (4 KB at 8.4 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-error-di
agnostics/2.0.6/maven-error-diagnostics-2.0.6.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-error-dia
gnostics/2.0.6/maven-error-diagnostics-2.0.6.pom (2 KB at 3.3 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/commons-cli/commons-cli/1.0/com
mons-cli-1.0.pom
Downloaded: http://repo.maven.apache.org/maven2/commons-cli/commons-cli/1.0/comm
ons-cli-1.0.pom (3 KB at 4.4 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-d
escriptor/2.0.6/maven-plugin-descriptor-2.0.6.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-de
scriptor/2.0.6/maven-plugin-descriptor-2.0.6.pom (2 KB at 4.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-inte
ractivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-inter
activity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.pom (7 KB at 13.6
KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-monitor/
2.0.6/maven-monitor-2.0.6.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-monitor/2
.0.6/maven-monitor-2.0.6.pom (2 KB at 2.4 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/classworlds/classworlds/1.1/cla
ssworlds-1.1.pom
Downloaded: http://repo.maven.apache.org/maven2/classworlds/classworlds/1.1/clas
sworlds-1.1.pom (4 KB at 6.7 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-util
s/2.0.5/plexus-utils-2.0.5.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils
/2.0.5/plexus-utils-2.0.5.pom (4 KB at 6.6 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/2.0.
6/plexus-2.0.6.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/2.0.6
/plexus-2.0.6.pom (17 KB at 21.9 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-f
iltering/1.1/maven-filtering-1.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-fi
ltering/1.1/maven-filtering-1.1.pom (6 KB at 11.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-s
hared-components/17/maven-shared-components-17.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-sh
ared-components/17/maven-shared-components-17.pom (9 KB at 15.3 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-util
s/1.5.15/plexus-utils-1.5.15.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils
/1.5.15/plexus-utils-1.5.15.pom (7 KB at 8.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/2.0.
2/plexus-2.0.2.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/2.0.2
/plexus-2.0.2.pom (12 KB at 13.9 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-inte
rpolation/1.12/plexus-interpolation-1.12.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-inter
polation/1.12/plexus-interpolation-1.12.pom (889 B at 1.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-comp
onents/1.1.14/plexus-components-1.1.14.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compo
nents/1.1.14/plexus-components-1.1.14.pom (6 KB at 10.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/sonatype/plexus/plexus-buil
d-api/0.0.4/plexus-build-api-0.0.4.pom
Downloaded: http://repo.maven.apache.org/maven2/org/sonatype/plexus/plexus-build
-api/0.0.4/plexus-build-api-0.0.4.pom (3 KB at 4.7 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/sonatype/spice/spice-parent
/10/spice-parent-10.pom
Downloaded: http://repo.maven.apache.org/maven2/org/sonatype/spice/spice-parent/
10/spice-parent-10.pom (3 KB at 5.3 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/sonatype/forge/forge-parent
/3/forge-parent-3.pom
Downloaded: http://repo.maven.apache.org/maven2/org/sonatype/forge/forge-parent/
3/forge-parent-3.pom (5 KB at 8.6 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-util
s/1.5.8/plexus-utils-1.5.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils
/1.5.8/plexus-utils-1.5.8.pom (8 KB at 13.4 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-inte
rpolation/1.13/plexus-interpolation-1.13.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-inter
polation/1.13/plexus-interpolation-1.13.pom (890 B at 1.4 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-comp
onents/1.1.15/plexus-components-1.1.15.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compo
nents/1.1.15/plexus-components-1.1.15.pom (3 KB at 4.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/2.0.
3/plexus-2.0.3.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/2.0.3
/plexus-2.0.3.pom (16 KB at 17.3 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-si
nk-api/1.0-alpha-7/doxia-sink-api-1.0-alpha-7.jar
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-inte
ractivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar
Downloading: http://repo.maven.apache.org/maven2/junit/junit/3.8.1/junit-3.8.1.j
ar
Downloading: http://repo.maven.apache.org/maven2/commons-cli/commons-cli/1.0/com
mons-cli-1.0.jar
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/reporting/mave
n-reporting-api/2.0.6/maven-reporting-api-2.0.6.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-sin
k-api/1.0-alpha-7/doxia-sink-api-1.0-alpha-7.jar (6 KB at 10.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-util
s/2.0.5/plexus-utils-2.0.5.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/reporting/maven
-reporting-api/2.0.6/maven-reporting-api-2.0.6.jar (10 KB at 11.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-f
iltering/1.1/maven-filtering-1.1.jar
Downloaded: http://repo.maven.apache.org/maven2/commons-cli/commons-cli/1.0/comm
ons-cli-1.0.jar (30 KB at 27.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/sonatype/plexus/plexus-buil
d-api/0.0.4/plexus-build-api-0.0.4.jar
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-inter
activity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar (14 KB at 10.4
KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-inte
rpolation/1.13/plexus-interpolation-1.13.jar
Downloaded: http://repo.maven.apache.org/maven2/junit/junit/3.8.1/junit-3.8.1.ja
r (119 KB at 73.9 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/sonatype/plexus/plexus-build
-api/0.0.4/plexus-build-api-0.0.4.jar (7 KB at 11.8 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-fi
ltering/1.1/maven-filtering-1.1.jar (43 KB at 38.9 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils
/2.0.5/plexus-utils-2.0.5.jar (218 KB at 91.8 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-inter
polation/1.13/plexus-interpolation-1.13.jar (60 KB at 28.9 KB/sec)
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e
. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\Development\workspace\maven_projec
t\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ hello-first -
--
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-a
pi/2.0.9/maven-plugin-api-2.0.9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-ap
i/2.0.9/maven-plugin-api-2.0.9.pom (2 KB at 3.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven/2.0.9/ma
ven-2.0.9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven/2.0.9/mav
en-2.0.9.pom (19 KB at 26.6 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/8
/maven-parent-8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/8/
maven-parent-8.pom (24 KB at 34.4 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/apache/4/apache-4.po
m
Downloaded: http://repo.maven.apache.org/maven2/org/apache/apache/4/apache-4.pom
(5 KB at 9.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-artifact
/2.0.9/maven-artifact-2.0.9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-artifact/
2.0.9/maven-artifact-2.0.9.pom (2 KB at 3.4 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-util
s/1.5.1/plexus-utils-1.5.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils
/1.5.1/plexus-utils-1.5.1.pom (3 KB at 4.8 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-core/2.0
.9/maven-core-2.0.9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-core/2.0.
9/maven-core-2.0.9.pom (8 KB at 11.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-settings
/2.0.9/maven-settings-2.0.9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-settings/
2.0.9/maven-settings-2.0.9.pom (3 KB at 4.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-model/2.
0.9/maven-model-2.0.9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-model/2.0
.9/maven-model-2.0.9.pom (4 KB at 6.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-p
arameter-documenter/2.0.9/maven-plugin-parameter-documenter-2.0.9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-pa
rameter-documenter/2.0.9/maven-plugin-parameter-documenter-2.0.9.pom (2 KB at 4.
2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-profile/
2.0.9/maven-profile-2.0.9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-profile/2
.0.9/maven-profile-2.0.9.pom (3 KB at 4.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-reposito
ry-metadata/2.0.9/maven-repository-metadata-2.0.9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-repositor
y-metadata/2.0.9/maven-repository-metadata-2.0.9.pom (2 KB at 3.9 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-error-di
agnostics/2.0.9/maven-error-diagnostics-2.0.9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-error-dia
gnostics/2.0.9/maven-error-diagnostics-2.0.9.pom (2 KB at 3.6 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-project/
2.0.9/maven-project-2.0.9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-project/2
.0.9/maven-project-2.0.9.pom (3 KB at 5.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-artifact
-manager/2.0.9/maven-artifact-manager-2.0.9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-artifact-
manager/2.0.9/maven-artifact-manager-2.0.9.pom (3 KB at 5.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-r
egistry/2.0.9/maven-plugin-registry-2.0.9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-re
gistry/2.0.9/maven-plugin-registry-2.0.9.pom (2 KB at 3.8 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-d
escriptor/2.0.9/maven-plugin-descriptor-2.0.9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-de
scriptor/2.0.9/maven-plugin-descriptor-2.0.9.pom (3 KB at 3.9 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-monitor/
2.0.9/maven-monitor-2.0.9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-monitor/2
.0.9/maven-monitor-2.0.9.pom (2 KB at 2.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-toolchai
n/1.0/maven-toolchain-1.0.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-toolchain
/1.0/maven-toolchain-1.0.pom (4 KB at 6.3 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-util
s/3.0/plexus-utils-3.0.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils
/3.0/plexus-utils-3.0.pom (4 KB at 7.8 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/sonatype/spice/spice-parent
/16/spice-parent-16.pom
Downloaded: http://repo.maven.apache.org/maven2/org/sonatype/spice/spice-parent/
16/spice-parent-16.pom (9 KB at 16.7 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/sonatype/forge/forge-parent
/5/forge-parent-5.pom
Downloaded: http://repo.maven.apache.org/maven2/org/sonatype/forge/forge-parent/
5/forge-parent-5.pom (9 KB at 15.8 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-comp
iler-api/1.9.1/plexus-compiler-api-1.9.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compi
ler-api/1.9.1/plexus-compiler-api-1.9.1.pom (867 B at 1.8 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-comp
iler/1.9.1/plexus-compiler-1.9.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compi
ler/1.9.1/plexus-compiler-1.9.1.pom (4 KB at 7.8 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-comp
onents/1.1.20/plexus-components-1.1.20.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compo
nents/1.1.20/plexus-components-1.1.20.pom (3 KB at 6.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/3.1/
plexus-3.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/3.1/p
lexus-3.1.pom (19 KB at 26.7 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/sonatype/spice/spice-parent
/17/spice-parent-17.pom
Downloaded: http://repo.maven.apache.org/maven2/org/sonatype/spice/spice-parent/
17/spice-parent-17.pom (7 KB at 13.9 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/sonatype/forge/forge-parent
/10/forge-parent-10.pom
Downloaded: http://repo.maven.apache.org/maven2/org/sonatype/forge/forge-parent/
10/forge-parent-10.pom (14 KB at 19.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-comp
iler-manager/1.9.1/plexus-compiler-manager-1.9.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compi
ler-manager/1.9.1/plexus-compiler-manager-1.9.1.pom (692 B at 1.3 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-comp
iler-javac/1.9.1/plexus-compiler-javac-1.9.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compi
ler-javac/1.9.1/plexus-compiler-javac-1.9.1.pom (688 B at 1.4 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-comp
ilers/1.9.1/plexus-compilers-1.9.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compi
lers/1.9.1/plexus-compilers-1.9.1.pom (2 KB at 2.6 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-util
s/3.0/plexus-utils-3.0.jar
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-comp
iler-javac/1.9.1/plexus-compiler-javac-1.9.1.jar
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-comp
iler-manager/1.9.1/plexus-compiler-manager-1.9.1.jar
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-comp
iler-api/1.9.1/plexus-compiler-api-1.9.1.jar
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compi
ler-manager/1.9.1/plexus-compiler-manager-1.9.1.jar (5 KB at 6.3 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compi
ler-javac/1.9.1/plexus-compiler-javac-1.9.1.jar (14 KB at 15.0 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compi
ler-api/1.9.1/plexus-compiler-api-1.9.1.jar (21 KB at 22.5 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils
/3.0/plexus-utils-3.0.jar (221 KB at 89.4 KB/sec)
[INFO] Nothing to compile - all classes are up to date
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:06 min
[INFO] Finished at: 2014-07-06T10:39:32+08:00
[INFO] Final Memory: 3M/7M
[INFO] ------------------------------------------------------------------------
D:\Development\workspace\maven_project>
我们看到maven执行了命令,并且从远程仓库下载了资源进行对项目进行编译,最后成功了。
这些远程资源会下载到我们电脑的:C:\Users\Administrator\.m2\repository 目录下面
然而,当我们的本地仓库中已经有了这些资源,在第二次执行上面的命令的时候,就不会到远程仓库中去获取资源,而是直接到本地仓库中获取。
下面是再次执行上面的命令:
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。 C:\Users\Administrator>D: D:\>cd D:\Development\workspace\maven_project D:\Development\workspace\maven_project>mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building hello-first SNAPSHOT-0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hello-firs
t ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e
. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\Development\workspace\maven_projec
t\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ hello-first -
--
[INFO] Nothing to compile - all classes are up to date
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.699 s
[INFO] Finished at: 2014-07-06T10:45:33+08:00
[INFO] Final Memory: 3M/7M
[INFO] ------------------------------------------------------------------------
D:\Development\workspace\maven_project>
2.执行命令:mvn test
D:\Development\workspace\maven_project>mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building hello-first SNAPSHOT-0.0.1
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
surefire-plugin/2.12.4/maven-surefire-plugin-2.12.4.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-s
urefire-plugin/2.12.4/maven-surefire-plugin-2.12.4.pom (11 KB at 12.7 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/suref
ire/2.12.4/surefire-2.12.4.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefi
re/2.12.4/surefire-2.12.4.pom (14 KB at 29.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
surefire-plugin/2.12.4/maven-surefire-plugin-2.12.4.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-s
urefire-plugin/2.12.4/maven-surefire-plugin-2.12.4.jar (30 KB at 33.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/junit/junit/4.10/junit-4.10.jar Downloading: http://repo.maven.apache.org/maven2/org/hamcrest/hamcrest-core/1.1/
hamcrest-core-1.1.jar
Downloaded: http://repo.maven.apache.org/maven2/org/hamcrest/hamcrest-core/1.1/h
amcrest-core-1.1.jar (75 KB at 48.7 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/junit/junit/4.10/junit-4.10.jar
(248 KB at 114.4 KB/sec)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hello-firs
t ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e
. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\Development\workspace\maven_projec
t\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ hello-first -
--
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ he
llo-first ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e
. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\Development\workspace\maven_projec
t\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ hello
-first ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ hello-first ---
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/suref
ire-booter/2.12.4/surefire-booter-2.12.4.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefi
re-booter/2.12.4/surefire-booter-2.12.4.pom (3 KB at 6.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/suref
ire-api/2.12.4/surefire-api-2.12.4.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefi
re-api/2.12.4/surefire-api-2.12.4.pom (3 KB at 5.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/maven
-surefire-common/2.12.4/maven-surefire-common-2.12.4.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/maven-
surefire-common/2.12.4/maven-surefire-common-2.12.4.pom (6 KB at 11.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/m
aven-plugin-annotations/3.1/maven-plugin-annotations-3.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/ma
ven-plugin-annotations/3.1/maven-plugin-annotations-3.1.pom (2 KB at 3.4 KB/sec) Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/m
aven-plugin-tools/3.1/maven-plugin-tools-3.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/ma
ven-plugin-tools/3.1/maven-plugin-tools-3.1.pom (16 KB at 23.3 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-util
s/3.0.8/plexus-utils-3.0.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils
/3.0.8/plexus-utils-3.0.8.pom (4 KB at 6.6 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/3.2/
plexus-3.2.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/3.2/p
lexus-3.2.pom (19 KB at 25.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/reporting/mave
n-reporting-api/2.0.9/maven-reporting-api-2.0.9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/reporting/maven
-reporting-api/2.0.9/maven-reporting-api-2.0.9.pom (2 KB at 3.4 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/reporting/mave
n-reporting/2.0.9/maven-reporting-2.0.9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/reporting/maven
-reporting/2.0.9/maven-reporting-2.0.9.pom (2 KB at 3.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-toolchai
n/2.0.9/maven-toolchain-2.0.9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-toolchain
/2.0.9/maven-toolchain-2.0.9.pom (4 KB at 7.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/commons/commons-lang
3/3.1/commons-lang3-3.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/commons/commons-lang3
/3.1/commons-lang3-3.1.pom (17 KB at 17.9 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/commons/commons-pare
nt/22/commons-parent-22.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/commons/commons-paren
t/22/commons-parent-22.pom (41 KB at 31.6 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/apache/9/apache-9.po
m
Downloaded: http://repo.maven.apache.org/maven2/org/apache/apache/9/apache-9.pom
(15 KB at 29.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-c
ommon-artifact-filters/1.3/maven-common-artifact-filters-1.3.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-co
mmon-artifact-filters/1.3/maven-common-artifact-filters-1.3.pom (4 KB at 7.8 KB/
sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-s
hared-components/12/maven-shared-components-12.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-sh
ared-components/12/maven-shared-components-12.pom (10 KB at 13.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/1
3/maven-parent-13.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/13
/maven-parent-13.pom (23 KB at 32.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/apache/6/apache-6.po
m
Downloaded: http://repo.maven.apache.org/maven2/org/apache/apache/6/apache-6.pom
(13 KB at 25.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-cont
ainer-default/1.0-alpha-9/plexus-container-default-1.0-alpha-9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-conta
iner-default/1.0-alpha-9/plexus-container-default-1.0-alpha-9.pom (2 KB at 2.6 K
B/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/suref
ire-booter/2.12.4/surefire-booter-2.12.4.jar
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/maven
-surefire-common/2.12.4/maven-surefire-common-2.12.4.jar
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-c
ommon-artifact-filters/1.3/maven-common-artifact-filters-1.3.jar
Downloading: http://repo.maven.apache.org/maven2/org/apache/commons/commons-lang
3/3.1/commons-lang3-3.1.jar
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/suref
ire-api/2.12.4/surefire-api-2.12.4.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-co
mmon-artifact-filters/1.3/maven-common-artifact-filters-1.3.jar (31 KB at 34.4 K
B/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-util
s/3.0.8/plexus-utils-3.0.8.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefi
re-booter/2.12.4/surefire-booter-2.12.4.jar (34 KB at 31.9 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/reporting/mave
n-reporting-api/2.0.9/maven-reporting-api-2.0.9.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefi
re-api/2.12.4/surefire-api-2.12.4.jar (115 KB at 75.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/m
aven-plugin-annotations/3.1/maven-plugin-annotations-3.1.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/reporting/maven
-reporting-api/2.0.9/maven-reporting-api-2.0.9.jar (10 KB at 18.7 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/ma
ven-plugin-annotations/3.1/maven-plugin-annotations-3.1.jar (14 KB at 28.4 KB/se
c)
Downloaded: http://repo.maven.apache.org/maven2/org/apache/commons/commons-lang3
/3.1/commons-lang3-3.1.jar (309 KB at 145.2 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/maven-
surefire-common/2.12.4/maven-surefire-common-2.12.4.jar (257 KB at 117.9 KB/sec) Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils
/3.0.8/plexus-utils-3.0.8.jar (227 KB at 116.0 KB/sec)
[INFO] Surefire report directory: D:\Development\workspace\maven_project\target\
surefire-reports
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/suref
ire-junit4/2.12.4/surefire-junit4-2.12.4.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefi
re-junit4/2.12.4/surefire-junit4-2.12.4.pom (3 KB at 5.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/suref
ire-providers/2.12.4/surefire-providers-2.12.4.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefi
re-providers/2.12.4/surefire-providers-2.12.4.pom (3 KB at 4.6 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/suref
ire-junit4/2.12.4/surefire-junit4-2.12.4.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefi
re-junit4/2.12.4/surefire-junit4-2.12.4.jar (37 KB at 33.0 KB/sec) -------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.b510.maven.hello.test.HelloTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.038 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.319 s
[INFO] Finished at: 2014-07-06T10:46:53+08:00
[INFO] Final Memory: 4M/8M
[INFO] ------------------------------------------------------------------------
D:\Development\workspace\maven_project>
上面是进行测试用例的编译和测试
下面进行打包操作
3.执行命令:mvn package
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。 C:\Users\Administrator>D: D:\>cd D:\Development\workspace\maven_project D:\Development\workspace\maven_project>mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building hello-first SNAPSHOT-0.0.1
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
jar-plugin/2.4/maven-jar-plugin-2.4.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-j
ar-plugin/2.4/maven-jar-plugin-2.4.pom (6 KB at 3.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
jar-plugin/2.4/maven-jar-plugin-2.4.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-j
ar-plugin/2.4/maven-jar-plugin-2.4.jar (34 KB at 36.3 KB/sec)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hello-firs
t ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e
. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\Development\workspace\maven_projec
t\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ hello-first -
--
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ he
llo-first ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e
. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\Development\workspace\maven_projec
t\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ hello
-first ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ hello-first ---
[INFO] Surefire report directory: D:\Development\workspace\maven_project\target\
surefire-reports -------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.b510.maven.hello.test.HelloTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.03 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ hello-first ---
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-archiver
/2.5/maven-archiver-2.5.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-archiver/
2.5/maven-archiver-2.5.pom (5 KB at 9.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-arch
iver/2.1/plexus-archiver-2.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archi
ver/2.1/plexus-archiver-2.1.pom (3 KB at 5.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-io/2
.0.2/plexus-io-2.0.2.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-io/2.
0.2/plexus-io-2.0.2.pom (2 KB at 3.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-comp
onents/1.1.19/plexus-components-1.1.19.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compo
nents/1.1.19/plexus-components-1.1.19.pom (3 KB at 5.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/3.0.
1/plexus-3.0.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/3.0.1
/plexus-3.0.1.pom (19 KB at 34.7 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-inte
rpolation/1.15/plexus-interpolation-1.15.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-inter
polation/1.15/plexus-interpolation-1.15.pom (1018 B at 2.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/commons-lang/commons-lang/2.1/c
ommons-lang-2.1.pom
Downloaded: http://repo.maven.apache.org/maven2/commons-lang/commons-lang/2.1/co
mmons-lang-2.1.pom (10 KB at 20.3 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-archiver
/2.5/maven-archiver-2.5.jar
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-io/2
.0.2/plexus-io-2.0.2.jar
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-inte
rpolation/1.15/plexus-interpolation-1.15.jar
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-arch
iver/2.1/plexus-archiver-2.1.jar
Downloading: http://repo.maven.apache.org/maven2/commons-lang/commons-lang/2.1/c
ommons-lang-2.1.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-archiver/
2.5/maven-archiver-2.5.jar (22 KB at 39.7 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-io/2.
0.2/plexus-io-2.0.2.jar (57 KB at 54.0 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-inter
polation/1.15/plexus-interpolation-1.15.jar (60 KB at 50.3 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/commons-lang/commons-lang/2.1/co
mmons-lang-2.1.jar (203 KB at 117.4 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archi
ver/2.1/plexus-archiver-2.1.jar (181 KB at 104.1 KB/sec)
[INFO] Building jar: D:\Development\workspace\maven_project\target\hello-first-S
NAPSHOT-0.0.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.989 s
[INFO] Finished at: 2014-07-06T10:49:01+08:00
[INFO] Final Memory: 4M/8M
[INFO] ------------------------------------------------------------------------
D:\Development\workspace\maven_project>
执行命令后,我们再来看看项目的结构:
这时候,我们发现,项目中多了target目录,这是maven生成了目录。
请注意看:hello-first-SNAPSHOT-0.0.1.jar文件,这个是根据我们在pom.xml中配置的artifactId = hello-first, version = SNAPSHOT-0.0.1所生成的。
4.执行命令:mvn clean
即清除掉target目录即target目录下面的所有文件
D:\Development\workspace\maven_project>mvn clean
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building hello-first SNAPSHOT-0.0.1
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
clean-plugin/2.5/maven-clean-plugin-2.5.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-c
lean-plugin/2.5/maven-clean-plugin-2.5.pom (4 KB at 5.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
clean-plugin/2.5/maven-clean-plugin-2.5.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-c
lean-plugin/2.5/maven-clean-plugin-2.5.jar (25 KB at 37.2 KB/sec)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ hello-first ---
[INFO] Deleting D:\Development\workspace\maven_project\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.066 s
[INFO] Finished at: 2014-07-06T10:55:13+08:00
[INFO] Final Memory: 2M/5M
[INFO] ------------------------------------------------------------------------
D:\Development\workspace\maven_project>
5.命令:mvn install
是把我们的资源加载到本地仓库中。
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。 C:\Users\Administrator>D: D:\>cd D:\Development\workspace\maven_project D:\Development\workspace\maven_project>mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building hello-first SNAPSHOT-0.0.1
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
install-plugin/2.4/maven-install-plugin-2.4.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-i
nstall-plugin/2.4/maven-install-plugin-2.4.pom (7 KB at 3.4 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
install-plugin/2.4/maven-install-plugin-2.4.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-i
nstall-plugin/2.4/maven-install-plugin-2.4.jar (27 KB at 37.0 KB/sec)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hello-firs
t ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e
. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\Development\workspace\maven_projec
t\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ hello-first -
--
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. buil
d is platform dependent!
[INFO] Compiling 1 source file to D:\Development\workspace\maven_project\target\
classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ he
llo-first ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e
. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\Development\workspace\maven_projec
t\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ hello
-first ---
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. buil
d is platform dependent!
[INFO] Compiling 1 source file to D:\Development\workspace\maven_project\target\
test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ hello-first ---
[INFO] Surefire report directory: D:\Development\workspace\maven_project\target\
surefire-reports -------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.b510.maven.hello.test.HelloTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.03 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ hello-first ---
[INFO] Building jar: D:\Development\workspace\maven_project\target\hello-first-S
NAPSHOT-0.0.1.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ hello-first ---
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-util
s/3.0.5/plexus-utils-3.0.5.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils
/3.0.5/plexus-utils-3.0.5.pom (3 KB at 5.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-dige
st/1.0/plexus-digest-1.0.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-diges
t/1.0/plexus-digest-1.0.pom (2 KB at 1.8 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-comp
onents/1.1.7/plexus-components-1.1.7.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compo
nents/1.1.7/plexus-components-1.1.7.pom (5 KB at 10.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/1.0.
8/plexus-1.0.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/1.0.8
/plexus-1.0.8.pom (8 KB at 10.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-cont
ainer-default/1.0-alpha-8/plexus-container-default-1.0-alpha-8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-conta
iner-default/1.0-alpha-8/plexus-container-default-1.0-alpha-8.pom (8 KB at 15.1
KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-util
s/3.0.5/plexus-utils-3.0.5.jar
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-dige
st/1.0/plexus-digest-1.0.jar
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-diges
t/1.0/plexus-digest-1.0.jar (12 KB at 16.1 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils
/3.0.5/plexus-utils-3.0.5.jar (226 KB at 115.9 KB/sec)
[INFO] Installing D:\Development\workspace\maven_project\target\hello-first-SNAP
SHOT-0.0.1.jar to C:\Users\Administrator\.m2\repository\com\b510\maven\hello\hel
lo-first\SNAPSHOT-0.0.1\hello-first-SNAPSHOT-0.0.1.jar
[INFO] Installing D:\Development\workspace\maven_project\pom.xml to C:\Users\Adm
inistrator\.m2\repository\com\b510\maven\hello\hello-first\SNAPSHOT-0.0.1\hello-
first-SNAPSHOT-0.0.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.014 s
[INFO] Finished at: 2014-07-06T10:57:39+08:00
[INFO] Final Memory: 5M/10M
[INFO] ------------------------------------------------------------------------
D:\Development\workspace\maven_project>
下面是运行后的效果:
这样做有什么用呢?
既然加载到了本地仓库,那么就类似于本地仓库中的junit模块一样,我们在使用junit的时候,只是在pom.xml文件中配置一下,并不需要引入junit的相关jar包,同理。
我们要使用/maven_project/src/com/b510/maven/hello/Hello.java类的时候,也不用引入该类的jar文件,只需要在pom.xml文件中配置即可。
如:
<dependencies>
<dependency>
<groupId>com.b510.maven.hello</groupId>
<artifactId>hello-first</artifactId>
<version>SNAPSHOT-0.0.1</version>
</dependency>
</dependencies>
第一个maven小程序,就差不多是这些,good luck!
========================================================
多读一些书,英语很重要。
More reading,and english is important.
I'm Hongten
========================================================
Maven的第一个小程序的更多相关文章
- TODO:即将开发的第一个小程序
TODO:即将开发的第一个小程序 微信小程序是一种全新的连接用户与服务的方式,它可以在微信内被便捷地获取和传播,同时具有出色的使用体验.个人理解小程序是寄宿在微信平台上的一个前端框架,具有跨平台功能, ...
- 微信小程序-----安装,编写第一个小程序和运行到手机端
第一步: 微信公众平台注册账号,并选择小程序,网址:mp.weixin.qq.com 填写相关信息,如:主体类型(个人或者企业) AppID 在开发中都是用的到的,服务器域名在网络请求也是用的到的. ...
- Struts2学习笔记——Struts2搭建和第一个小程序
1.新建web项目 2.配置Struts2核心过滤器 (1)打开web.xml文件,做以下配置: <?xml version="1.0" encoding="UTF ...
- 自学Android的第一个小程序(小布局、button点击事件、toast弹出)
因为上班,学习时间有限,昨晚才根据教程写了一个小程序,今天忙里偷闲写一下如何实现的,来加深一下印象. 首先创建一个Android项目, 通过activity_xxx.xml布局文件来添加组件来达到自己 ...
- 动手搭建第一个小程序音视频Demo
欢迎大家前往云+社区,获取更多腾讯海量技术实践干货哦~ 作者:小程序音视频产品经理 腾讯云提供了全套技术文档和源码来帮助您快速构建一个音视频小程序,但是再好的源码和文档也有学习成本,为了尽快的能调试起 ...
- 微信小程序——创建自己的第一个小程序【一】
注册 微信小程序注册 https://mp.weixin.qq.com/wxopen/waregister?action=step1 填写账号信息 作为登录帐号,请填写未被微信公众平台注册,未被 ...
- python3速查参考- python基础 1 -> python版本选择+第一个小程序
题外话: Python版本:最新的3.6 安装注意点:勾选添加路径后自定义安装到硬盘的一级目录,例如本人的安装路径: F:\Python 原因:可以自动添加python环境变量,自动关联.py文件,其 ...
- Python 的第一个小程序
F盘 新建文本文档 hello.txt 内容为: print("hello world! hello 2018!"); 打开CMD cd c:\ ...
- [开源]入坑Qt,我的第一个小程序:MD5计算器
版权声明 --------- 本文仅在知乎与博客园发布.开发者为szx0427 MFC和Win32搞了好几年了,也算是懂了个皮毛,但是一直觉得用这两者开发软件都很麻烦,需要将大量的代码花费在UI等地方 ...
随机推荐
- .Learning.Python.Design.Patterns.2nd.Edition之单实例模式
可以慢慢理解.. 对照JAVA class Singleton(object): def __new__(cls): if not hasattr(cls, 'instance'): cls.inst ...
- 无废话ExtJs 入门教程五[文本框:TextField]
无废话ExtJs 入门教程五[文本框:TextField] extjs技术交流,欢迎加群(201926085) 继上一节内容,我们在表单里加了个两个文本框.如下所示代码区的第42行位置,items: ...
- DevExpress DXperience 的本地化(汉化)方法
Devexpress的.net组件目前非常流行,在国内开发者中有非常高的热度,但是由于是国外控件,我们经常遇到的一个问题是汉化.目前Devexpress公司2011.2版以后使用了统一的本地化模式,针 ...
- IOS 100 - 1 开工闲聊
1 前言 现在的行情,作为码农,ios 普遍比c# 的待遇好上不少.感觉就如清洁工人,扫厕所干的再高效和干净,一个月就那么点微薄的收入.当然你可以选择去香港打扫卫生间,那里的行情据说清洁工也破万了.说 ...
- [Surface] 在win8.1上使用QQ截图放大问题(解决办法)
在使用每次截图的时候整个都被放大了,很让人郁闷,截不到完整的图,本着遇到问题解决问题的想法,这事早解决早好. 开工: 1. 度娘上搜索"win8 qq截图 放大",找到很多资料 ...
- 字幕文件 WebVTT 与 srt 之间的互相转化
1. WebVTT 2 srt 1. 用记事本打开 .vtt 文件: 2. 在记事本中点击 编辑 -> 替换 -> 查找内容中输入".",替换为中输入",& ...
- 利用Visual GDB在Visual Studio中进行Android开发
转载请注明http://www.cnblogs.com/adong7639/p/4119467.html 无意中发现了Visual GDB这个工具,可以再Visual Studio中进行Android ...
- 湖南省第十二届大学生计算机程序设计竞赛 B 有向无环图 拓扑DP
1804: 有向无环图 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 187 Solved: 80[Submit][Status][Web Board ...
- 关于html中的设置body宽高的理解
有时候看到别人的代码中经常出现在body中设置的宽高,不是很理解,于是自己测试了下,瞬间懂了,废话不多说,直接上代码: 首先创建好一个基本的html文件,设body的背景色为red: 相信大家都知道效 ...
- 通信原理实践(四)——模拟通信系统性能分析
一.模拟通信系统性能分析 1.系统框图 2.信噪比定义 (1)输入信噪比: (2)输出信噪比: (3)调制制度增益: 3.模拟通信系统分析等价模型 即自己产生一个高斯白噪声,加入到调制信号,然后在送入 ...