1、创建struts2项目:
[url=http://struts.apache.org/2.0.11.1/docs/ready-set-go.html]reference[/url]
如果需要使用struts2的snapshot版本,需要在POM.XML中添加:
2、然后使用 mvn -Dwtpversion=1.0 eclipse:eclipse
建立Eclipse项目。
3、struts2需要jdk1.5以上的tools.jar,如果maven不能定位到,手动添加:
4、如果安装m2eclipse,使用m2eclipse管理项目。
可能需要将mvn生成的[Java Build Path]里的repo链接删除,用m2ecipse自动管理。
5、在project->properties->J2EE Module Dependencies 选取需要的Jar/Moule.
这将自动把需要的lib拷贝到容器对于的lib目录。
[url=http://struts.apache.org/2.0.11.1/docs/ready-set-go.html]reference[/url]
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目录。