IDE工具为 idea 10.5.1
首先配置maven环境,不配置也行,只要将maven包下载解压缩,然后在idea中设置 file-setting maven homedirectory为你的maven文件夹地址就可以了
1. 用Maven2 搭建struts2.18项目
IDE工具为 idea 10.5.1
先创建项目骨架部分
mvnarchetype:create -DgroupId=com.mycompany.app -DartifactId=my-webapp-DarchetypeArtifactId=maven-archetype-webapp
命令说明:
archetype
groupId 项目的java包结构:com
artifactId 项目的名称:certusSimple
archetypeArtifactId(项目骨架的类型):
* maven-archetype-archetype
* maven-archetype-j2ee-simple
* maven-archetype-mojo
* maven-archetype-portlet
* maven-archetype-profiles (currently underdevelopment)
* maven-archetype-quickstart
* maven-archetype-simple (currently underdevelopment)
* maven-archetype-site
* maven-archetype-site-simple, and
* maven-archetype-webapp
Pom.xml文件
<?xml version="1.0"encoding="UTF-8"?>
<projectxmlns="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.0http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- 项目或者组织的唯一标志,并且配置时生成的路径也是由此生成 -->
<groupId>my.web</groupId>
<!--项目的通用名称-->
<artifactId>cat</artifactId>
<!--打包的机制,如pom,jar, maven-plugin, ejb, war, ear, rar, par-->
<packaging>war</packaging>
<!-- 项目的版本 -->
<version>1.0</version>
<!-- 项目除了artifactId外,可以定义别名 -->
<name>web</name>
<!-- 开发者 -->
<developers>
<developer>
<id>mars</id>
<name>Ryan</name>
<roles>
<role>开发</role>
<role>测试</role>
</roles>
<email>993985246@qq.com</email>
<timezone>+8</timezone>
</developer>
<developer>
<id>mars</id>
<name>whjzuiai</name>
<roles>
<role>开发</role>
</roles>
<email>76513716@qq.com</email>
<timezone>+8</timezone>
</developer>
</developers>
<dependencies>
<!-- 依赖 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!--这里下面的两个dependency,servlet-api与jsp-api所需-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.1.8.1</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-tiles-plugin</artifactId>
<version>2.1.8.1</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>2.0.4</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
<!--主要用于编译设置,包括两个主要的元素,build和reporting-->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<wtpmanifest>true</wtpmanifest>
<wtpapplicationxml>true</wtpapplicationxml>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<links>
<link>http://gceclub.sun.com.cn/Java_Docs/jdk6/html/zh_CN/api</link>
</links>
<aggregate>true</aggregate>
</configuration>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<configuration>
<locales>zh_CN</locales>
<outputEncoding>UTF-8</outputEncoding>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.6</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>surefire-report-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<links>
<link>http://gceclub.sun.com.cn/Java_Docs/jdk6/html/zh_CN/api</link>
</links>
<aggregate>true</aggregate>
<charset>UTF-8</charset>
<docencoding>UTF-8</docencoding>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</reporting>
</project>