使用maven构建ssi项目:
1、eclipse安装maven插件;
2、new->maven-project->artifact Id : maven-archetype-webapp->下一步:
3、填写groupId:包名;artifact Id:项目工程名;
4、配置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.lz.maven.ssi</groupId> <artifactId>maven-ssi</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>maven-ssi</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> </dependency> <!-- 导入struts需要的jar --> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>2.3.1.2</version> </dependency> <!-- log --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.14</version> </dependency> <!-- spring需要配置的jar --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>3.1.3.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>3.1.3.RELEASE</version> </dependency> <!-- spring integration --> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-spring-plugin</artifactId> <version>2.3.1.2</version> </dependency> <!-- mybatis配置 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.0.1</version> </dependency> <!-- json --> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.1</version> </dependency> <!-- mysql --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.18</version> </dependency> <!-- 数据库连接池 --> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.4</version> </dependency> </dependencies> <build> <finalName>${project.name}</finalName> <sourceDirectory>src/main/java</sourceDirectory> <outputDirectory>target/${project.name}/WEB-INF/classes/</outputDirectory> <resources> <resource> <directory>src/main/resources/</directory> <excludes> <exclude>*/**/*.class</exclude> </excludes> </resource> </resources> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build> </project>
5、配置相应的web.xml、struts、spring以及mybatis相关配置文件,同一般工程配置;
6、右键工程,run->maven-install;
7、将工程部署到tomcat,双击tomcat,点击modules,点击“add external web module”->选择项目工程->工程目录下target目录下的工程,启动服务器;