2008-04-14

struts2 & maven

1、创建struts2项目:
reference

mvn archetype:create -DgroupId=tutorial \
         -DartifactId=tutorial \
         -DarchetypeGroupId=org.apache.struts \
         -DarchetypeArtifactId=struts2-archetype-starter \
         -DarchetypeVersion=2.0.9-SNAPSHOT \
         -DremoteRepositories=http://people.apache.org/repo/m2-snapshot-repository


如果需要使用struts2的snapshot版本,需要在POM.XML中添加:
<dependency>
  <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
      <version>2.1.1</version>
</dependency>

<repositories>
  <repository>
    <id>apache.snapshots</id>
    <name>ASF Maven 2 Snapshot</name>
    <url>http://people.apache.org/repo/m2-snapshot-repository</url>
  </repository>
</repositories>

2、然后使用 mvn -Dwtpversion=1.0 eclipse:eclipse
建立Eclipse项目。

3、struts2需要jdk1.5以上的tools.jar,如果maven不能定位到,手动添加:
		<dependency>
			<groupId>com.sun</groupId>
			<artifactId>tools</artifactId>
			<version>1.5.0</version>
			<scope>system</scope>
			<systemPath>
				C:/Program Files/Java/jdk1.6.0/lib/tools.jar
			</systemPath>
		</dependency>


4、如果安装m2eclipse,使用m2eclipse管理项目。
可能需要将mvn生成的[Java Build Path]里的repo链接删除,用m2ecipse自动管理。

5、在project->properties->J2EE Module Dependencies 选取需要的Jar/Moule.
这将自动把需要的lib拷贝到容器对于的lib目录。
评论
发表评论

您还没有登录,请登录后发表评论

bigzerg
搜索本博客
最近加入圈子
最新评论