SSH 整合 (Maven)

来源:互联网 发布:c 中a 算法求解8数码 编辑:程序博客网 时间:2024/06/04 17:53

1.SSH 教程详见我的上一篇博客 SSH(Struts 2.3.31 + Spring 4.1.6 + Hibernate 5.0.12 + Ajax)框架整合实现简单的增删改查(包含分页,Ajax 无刷新验证该用户是否存在)

(地址如下:http://www.cnblogs.com/yjq520/p/6705959.html)

2.Maven 的 pom.xml 配置如下,然后 maven 方式启动运行

<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.cqvie</groupId>  <artifactId>SSH_Maven</artifactId>  <packaging>war</packaging>  <version>1.0</version>  <name>SSH_Demo Maven Webapp</name>  <url>http://maven.apache.org</url>  <repositories><!--设置maven组件仓库 -->        <!-- maven官方仓库 -->        <repository>            <id>maven</id>            <name>Maven Repository Switchboard</name>            <layout>default</layout>            <url>http://repo1.maven.org/maven2</url>            <snapshots>                <enabled>false</enabled>            </snapshots>        </repository>        <!-- 阿里巴巴发布版本仓库 -->        <repository>            <id>alibaba-opensource</id>            <name>alibaba-opensource</name>            <url>http://code.alibabatech.com/mvn/releases/</url>            <layout>default</layout>        </repository>    </repositories>  <dependencies>      <!-- Servlet API -->    <dependency>        <groupId>javax.servlet</groupId>        <artifactId>javax.servlet-api</artifactId>        <version>3.1.0</version>        <scope>provided</scope> <!-- 编译时用到servlet-api和jsp-api,但在打包的时候不用这两个依赖 -->    </dependency>    <!-- JSP API -->    <dependency>        <groupId>javax.servlet.jsp</groupId>        <artifactId>jsp-api</artifactId>        <version>2.2</version>        <scope>provided</scope> <!-- 编译时用到servlet-api和jsp-api,但在打包的时候不用这两个依赖 -->    </dependency>    <!-- MySQL -->    <dependency>        <groupId>mysql</groupId>        <artifactId>mysql-connector-java</artifactId>        <version>5.1.6</version>    </dependency>    <!-- JUnit -->    <dependency>        <groupId>junit</groupId>        <artifactId>junit</artifactId>        <version>4.11</version>        <scope>test</scope>    </dependency>    <!-- log4j-core -->    <dependency>        <groupId>org.apache.logging.log4j</groupId>        <artifactId>log4j-core</artifactId>        <version>2.6.2</version>    </dependency>    <!-- asm -->    <dependency>        <groupId>org.ow2.asm</groupId>        <artifactId>asm-commons</artifactId>        <version>5.0.4</version>    </dependency>    <!-- aopalliance -->    <dependency>        <groupId>aopalliance</groupId>        <artifactId>aopalliance</artifactId>        <version>1.0</version>    </dependency>    <!-- aspectjweaver -->    <dependency>        <groupId>org.aspectj</groupId>        <artifactId>aspectjweaver</artifactId>        <version>1.8.9</version>    </dependency>    <!-- Spring -->    <dependency>        <groupId>org.springframework</groupId>        <artifactId>spring-orm</artifactId>        <version>4.3.2.RELEASE</version>    </dependency>    <dependency>        <groupId>org.springframework</groupId>        <artifactId>spring-context</artifactId>        <version>4.3.2.RELEASE</version>    </dependency>    <dependency>        <groupId>org.springframework</groupId>        <artifactId>spring-web</artifactId>        <version>4.3.2.RELEASE</version>    </dependency>    <!-- Hibernate -->    <dependency>        <groupId>org.hibernate</groupId>        <artifactId>hibernate-core</artifactId>        <version>5.1.5.Final</version>    </dependency>    <!-- Struts2 -->    <dependency>        <groupId>org.apache.struts</groupId>        <artifactId>struts2-core</artifactId>        <version>2.3.31</version>    </dependency>    <dependency>        <groupId>org.apache.struts</groupId>        <artifactId>struts2-spring-plugin</artifactId>        <version>2.3.31</version>    </dependency>    <!-- DBCP2 -->    <dependency>        <groupId>org.apache.commons</groupId>        <artifactId>commons-dbcp2</artifactId>        <version>2.1.1</version>    </dependency>  </dependencies>  <build>    <finalName>SSH_Maven</finalName>    <!-- Maven项目编译插件 -->    <plugins>        <plugin>            <artifactId>maven-compiler-plugin</artifactId>            <version>2.3.2</version>    <!-- 不指定时默认采用最新插件版本 -->            <configuration>                <!-- 根据实际情况设置 JDK -->                <source>1.7</source>    <!-- 源代码使用的开发版本 -->                <target>1.7</target>    <!-- 需要生成的目标class文件的编译版本 -->                <encoding>UTF-8</encoding>            </configuration>        </plugin><!--         <plugin>            <groupId>org.apache.maven.plugins</groupId>            <artifactId>maven-surefire-plugin</artifactId>            <version>2.17</version>            <configuration>                <testFailureIgnore>true</testFailureIgnore>            </configuration>        </plugin> -->        <plugin>            <groupId>org.apache.tomcat.maven</groupId>            <artifactId>tomcat7-maven-plugin</artifactId>            <version>2.2</version>            <configuration>                <!-- 使用内置的模拟Tomcat服务器 -->                <path>/SSH_Maven</path>                <uriEncoding>UTF-8</uriEncoding>                <port>9527</port>                <mode>context</mode>                <!-- <contextFile>src/main/webapp/META-INF/context.xml</contextFile> -->                <contextReloadable>true</contextReloadable>                <!-- <backgroundProcessorDelay>5</backgroundProcessorDelay> -->            </configuration>        </plugin>    </plugins>  </build></project>pom.xml

这里写图片描述

这里写图片描述