一、环境

  系统:Windows7

  IDE:Eclipse-Kepler Service Release 2

  使用插件:Maven(请预先在电脑上安装Maven)

 

二、搭建

在Eclipse中新建一个Maven工程:

  【Web】Eclipse + Maven + Struts搭建服务器

选择Maven Project。

【Web】Eclipse + Maven + Struts搭建服务器

注意选择maven-archetype-web选项。Catalog处,点击右边的Configuration按钮,弹出对话框:

【Web】Eclipse + Maven + Struts搭建服务器

点击右边的Add remote Catalog,在Catalog file输入框中输入http://repo1.maven.org/maven2/archetype-catalog.xml,Description则随便输入(等于去一个名字)然后点击OK,继续Next。

【Web】Eclipse + Maven + Struts搭建服务器

在此处输入项目的group id和artifact id。点击Finish。此时项目的目录结构如下:

【Web】Eclipse + Maven + Struts搭建服务器

项目报错误,暂时可以不用管。下面继续配置。因为要用到Struts2,所以需要依赖很多相应的jar包,这就是使用Maven的目的,下面修改Maven的pom文件如下:

 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 2     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 3     <modelVersion>4.0.0</modelVersion>
 4     <groupId>com.amos</groupId>
 5     <artifactId>struts2</artifactId>
 6     <packaging>war</packaging>
 7     <version>0.0.1-SNAPSHOT</version>
 8     <name>struts2 Maven Webapp</name>
 9     <url>http://maven.apache.org</url>
10     <dependencies>
11         <dependency>
12             <groupId>junit</groupId>
13             <artifactId>junit</artifactId>
14             <version>3.8.1</version>
15             <scope>test</scope>
16         </dependency>
17         <dependency>
18             <groupId>org.apache.struts</groupId>
19             <artifactId>struts2-core</artifactId>
20             <version>2.3.16</version>
21         </dependency>
22         <dependency>
23             <groupId>org.apache.commons</groupId>
24             <artifactId>commons-io</artifactId>
25             <version>1.3.2</version>
26         </dependency>
27     </dependencies>
28     <build>
29         <finalName>struts2</finalName>
30     </build>
31 </project>
View Code

相关文章:

  • 2021-12-06
  • 2021-10-26
  • 2021-10-30
  • 2021-06-01
  • 2022-12-23
  • 2021-08-09
  • 2021-12-06
猜你喜欢
  • 2021-12-09
  • 2022-12-23
  • 2021-08-09
  • 2021-09-29
  • 2021-10-29
相关资源
相似解决方案