再用Maven2

上次用Maven只是别人搭建好的工程,我们使用,今天项目不多,自己动手来建个Maven2的项目.
1
下载安装我就不说了,如遇问题请google
建Java工程
命令:mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app
在目录下就会新建一个项目名称为my-app的Java项目,下面的包结构就是com.mycompany.app
You will notice a few things happened when you executed this command. First, you will notice that a
directory named my-app has been created for the new project, and this directory contains your
pom.xml, which looks like the following:

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Maven Quick Start Archetype</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

2
编译mvn工程 mvn compile
测试mvn工程 mvn test
不编译只测试mvn工程 mvn test-compile
打包成为jar包,可以布的 mvn package
下载依赖类库 mvn install
发布成site形式 mvn site
This will remove the target directory with the old build data before starting, so it is fresh
清空原来老的类库 mvn clean
(注意是clean不是clear)
更改为eclipse工程 mvn eclipse:eclipse

如果有一些资源文件,如图片或配置文件需要一同打包发布的,请在src/main/下新建文件夹resources,,所有文件放在该位置.测试类的资源文件是src/test/resources/下放置.这样这些资源文件就会在mvn package随同jar包一同发布,调用该资源文件时直接用 "/xx.properties" 或 "/xx.gif".

// Retrieve resource
InputStream is = getClass().getResourceAsStream( "/test.properties" );


3 用Maven2创建J2EE工程,由于现在的Eclipse6.5集成了这个plugsin,所以具体操作我不在这里写了,只要去下载了Myeclipse6.5,然后用中国特色的在google上搜索myeclipse6.5注册码,即可crack.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值