使用maven轻松创建java web项目

使用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 完成编译打包。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值