再用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.


你可能感兴趣的:(apache,eclipse,maven,JUnit,Google)