使用maven,我们可以很简单的创建和管理一个项目。
首先,我们使用如下命令创建一个项目:
mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=com.yuan -DartifactId=jsontest -DarchetypeArtifactId=maven-archetype-webapp
通过上面的命令,我们就创建了pom.xml文件以及项目目录。我们需要根据项目的要求,编辑pom.xml。
首先要确定jdk的版本,在pom中添加:
<build> <finalName>jsontest</finalName> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build>
如果需要使用其他的mvn repository, 可以添加:
<repositories> <repository> <id>gson</id> <url>http://google-gson.googlecode.com/svn/mavenrepo</url> <snapshots><enabled>true</enabled></snapshots> <releases><enabled>true</enabled></releases> </repository> </repositories>
根据需要的jar,添加dependency。
通过mvn eclipse:eclipse来创建eclipse项目文件。
通过mvn clean install 完成编译打包。