标签:
在Eclipse中使用Maven创建SpringMVC项目,项目所需软件及工具可以在官网下载。Maven、Nexus及Eclipse集成Maven等到此配置完毕。
1、Maven创建Web项目、
打开Eclipse,File——》New——》other——》Maven——》Maven Project
选择好创建Maven项目后点击Next进行下一步操作,选择项目存放位置,点击Next。
至此项目创建成功,具体结构如下:
2、添加所需Jar包,打开工程下面的pom.xml文件。内容如下
<project xmlns="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.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.akwl.main</groupId> <artifactId>SpringMVC_Test</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>SpringMVC_Test Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <finalName>SpringMVC_Test</finalName> </build> </project>
修改pom.xml,将项目所需的Jar包添加进工程
<project xmlns="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.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.akwl.main</groupId> <artifactId>WebSystem</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>WebSystem Maven Webapp</name> <url>http://maven.apache.org</url> <properties> <project.springframework.version>4.0.6.RELEASE</project.springframework.version> <project.springframework.groupId>org.springframework</project.springframework.groupId> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <!-- c3po --> <dependency> <groupId>com.mchange</groupId> <artifactId>c3p0</artifactId> <version>0.9.2.1</version> </dependency> <dependency> <groupId>${project.springframework.groupId}</groupId> <artifactId>spring-jdbc</artifactId> <version>${project.springframework.version}</version> </dependency> <!-- start spring 核心依赖包 --> <dependency> <groupId>${project.springframework.groupId}</groupId> <artifactId>spring-core</artifactId> <version>${project.springframework.version}</version> </dependency> <dependency> <groupId>${project.springframework.groupId}</groupId> <artifactId>spring-context</artifactId> <version>${project.springframework.version}</version> </dependency> <dependency> <groupId>${project.springframework.groupId}</groupId> <artifactId>spring-context-support</artifactId> <version>${project.springframework.version}</version> </dependency> <dependency> <groupId>${project.springframework.groupId}</groupId> <artifactId>spring-aop</artifactId> <version>${project.springframework.version}</version> </dependency> <dependency> <groupId>${project.springframework.groupId}</groupId> <artifactId>spring-aspects</artifactId> <version>${project.springframework.version}</version> </dependency> <dependency> <groupId>${project.springframework.groupId}</groupId> <artifactId>spring-tx</artifactId> <version>${project.springframework.version}</version> </dependency> <dependency> <groupId>${project.springframework.groupId}</groupId> <artifactId>spring-beans</artifactId> <version>${project.springframework.version}</version> </dependency> <!-- end spring 核心依赖包 --> <!-- start spring mvc --> <dependency> <groupId>${project.springframework.groupId}</groupId> <artifactId>spring-web</artifactId> <version>${project.springframework.version}</version> </dependency> <dependency> <groupId>${project.springframework.groupId}</groupId> <artifactId>spring-webmvc</artifactId> <version>${project.springframework.version}</version> </dependency> <!-- end spring mvc --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>5.1.2.Final</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <!-- START SERVLET --> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.1</version> <scope>provided</scope> </dependency> <!--文件上传 --> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>1.3</version> </dependency> <!-- 转json --> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.2.4</version> </dependency> <!-- POI Excel数据导入包begin --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.10-FINAL</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml-schemas</artifactId> <version>3.10-FINAL</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.10-FINAL</version> </dependency> <dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> <version>1.6.1</version> <type>pom</type> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>openxml4j</artifactId> <version>1.0-beta</version> </dependency> <dependency> <groupId>org.apache.xmlbeans</groupId> <artifactId>xmlbeans</artifactId> <version>2.6.0</version> </dependency> <!-- POI Excel数据导入包end --> </dependencies> <build> <finalName>WebSystem</finalName> </build> </project>
修改完pom.xml文件后跟新项目。在项目——》maven——》Update Project
标签:
原文地址:http://www.cnblogs.com/peter072588/p/4414202.html