1.新建一个工程目录,如“c:/project”,在控制台“c:\project”目录下,执行命令mvn archetype:create -DgroupId=com.qincao.first -DartifactId=qincao-first,生成目录qincao-first。
2.在c:\project\qincao-first目录下,新建src/main/resources src/test/resources 目录。
3.在c:\project\qincao-first目录,执行mvn eclipse:eclipse生成eclipse工程。
4.在c:\project\qincao-first\pom.xml为maven配置文件,内容如下:
<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.qincao.first</groupId> <artifactId>qincao-first</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>qincao-first</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>
5.eclipse可以直接运行com.qincao.first.App.java和com.qincao.first.AppTest.java。