Maven的第一个小程序
发布时间:2020-12-14 06:30:45 所属栏目:Java 来源:网络整理
导读:这里是介绍关于maven的第一个小程序 关于maven的安装 : 先看看目录结构: 这是本来的项目目录结构,由于maven有自己的目录结构,所以,下面的是加入maven元素后的目录结构: 即: NOTE: 你所看到的有红色X标示错误提示,这是在Eclipse中的提示,这个可以不
这里是介绍关于maven的第一个小程序 关于maven的安装 : 先看看目录结构: 这是本来的项目目录结构,由于maven有自己的目录结构,所以,下面的是加入maven元素后的目录结构: 即:
NOTE: 你所看到的有红色X标示错误提示,这是在Eclipse中的提示,这个可以不用理会。 接下来才是关键:
4.0.0
com.b510.maven.hello
hello-first
SNAPSHOT-0.0.1
junit
junit
4.10
test
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类
System.out.println("This is a test message!" String str = Hello().sayHello("Hongten",20
String sayHello(String name, "I'm " + name + ",I'm " + age + ",Hello" }
org.junit.Assert.*
Hello hello = assertEquals(hello.sayHello("Hongten",20),"I'm Hongten,I'm 20,Hello"
}
两个类都是很简单的类。 现在我们启动windows的控制台。即运行--> cmd,或Ctrl+R --> cmd 进入到项目的根目录:D:Developmentworkspacemaven_project ?
由于我们本地仓库中没有编译所需要的资源,所有,maven会到远程仓库中去获取资源到本地 下面是控制台运行效果:这里只是截取了部分log Downloading: http:
arameter-documenter/2.0.6/maven-plugin-parameter-documenter-2.0.6 Downloaded: http:
rameter-documenter/2.0.6/maven-plugin-parameter-documenter-2.0.6.pom (2 KB at 3 8 KB/ Downloading: http:
n-reporting-api/2.0.6/maven-reporting-api-2.0.6 Downloaded: http:
-reporting-api/2.0.6/maven-reporting-api-2.0.6.pom (2 KB at 3.8 KB/ Downloading: http:
n-reporting/2.0.6/maven-reporting-2.0.6 Downloaded: http:
-reporting/2.0.6/maven-reporting-2.0.6.pom (2 KB at 3.2 KB/ Downloading: http:
nk-api/1.0-alpha-7/doxia-sink-api-1.0-alpha-7 Downloaded: http:
k-api/1.0-alpha-7/doxia-sink-api-1.0-alpha-7.pom (424 B at 0.9 KB/ Downloading: http:
0-alpha-7/doxia-1.0-alpha-7 Downloaded: http:
-alpha-7/doxia-1.0-alpha-7.pom (4 KB at 8.4 KB/ Downloading: http:
agnostics/2.0.6/maven-error-diagnostics-2.0.6 Downloaded: http:
gnostics/2.0.6/maven-error-diagnostics-2.0.6.pom (2 KB at 3.3 KB/ Downloading: http:
mons-cli-1.0 Downloaded: http:
ons-cli-1.0.pom (3 KB at 4.4 KB/ Downloading: http:
escriptor/2.0.6/maven-plugin-descriptor-2.0.6 Downloaded: http:
scriptor/2.0.6/maven-plugin-descriptor-2.0.6.pom (2 KB at 4.0 KB/ Downloading: http:
ractivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4 Downloaded: http:
activity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.pom (7 KB at 13.6
KB/ Downloading: http:
2.0.6/maven-monitor-2.0.6 Downloaded: http:
.0.6/maven-monitor-2.0.6.pom (2 KB at 2.4 KB/ Downloading: http:
ssworlds-1.1 Downloaded: http:
sworlds-1.1.pom (4 KB at 6.7 KB/ Downloading: http:
s/2.0.5/plexus-utils-2.0.5 Downloaded: http:
/2.0.5/plexus-utils-2.0.5.pom (4 KB at 6.6 KB/ Downloading: http:
6/plexus-2.0.6 Downloaded: http:
/plexus-2.0.6.pom (17 KB at 21.9 KB/ Downloading: http:
iltering/1.1/maven-filtering-1.1 Downloaded: http:
ltering/1.1/maven-filtering-1.1.pom (6 KB at 11.5 KB/ Downloading: http:
hared-components/17/maven-shared-components-17 Downloaded: http:
ared-components/17/maven-shared-components-17.pom (9 KB at 15.3 KB/ Downloading: http:
s/1.5.15/plexus-utils-1.5.15 Downloaded: http:
/1.5.15/plexus-utils-1.5.15.pom (7 KB at 8.1 KB/ Downloading: http:
2/plexus-2.0.2 Downloaded: http:
/plexus-2.0.2.pom (12 KB at 13.9 KB/ Downloading: http:
rpolation/1.12/plexus-interpolation-1.12 Downloaded: http:
polation/1.12/plexus-interpolation-1.12.pom (889 B at 1.5 KB/ Downloading: http:
onents/1.1.14/plexus-components-1.1.14 Downloaded: http:
nents/1.1.14/plexus-components-1.1.14.pom (6 KB at 10.1 KB/ Downloading: http:
d-api/0.0.4/plexus-build-api-0.0.4 Downloaded: http:
-api/0.0.4/plexus-build-api-0.0.4.pom (3 KB at 4.7 KB/ Downloading: http:
/10/spice-parent-10 Downloaded: http:
10/spice-parent-10.pom (3 KB at 5.3 KB/ Downloading: http:
/3/forge-parent-3 Downloaded: http:
3/forge-parent-3.pom (5 KB at 8.6 KB/ Downloading: http:
s/1.5.8/plexus-utils-1.5.8 Downloaded: http:
/1.5.8/plexus-utils-1.5.8.pom (8 KB at 13.4 KB/ Downloading: http:
rpolation/1.13/plexus-interpolation-1.13 Downloaded: http:
polation/1.13/plexus-interpolation-1.13.pom (890 B at 1.4 KB/ Downloading: http:
onents/1.1.15/plexus-components-1.1.15 |