SSH 整合 (Maven)

1.SSH 教程詳見個人上一篇博客 SSH(Struts 2.3.31 + Spring 4.1.6 + Hibernate 5.0.12 + Ajax)框架整合實現簡單的增刪改查(包含分頁,Ajax 無刷新驗證該用戶是否存在)html

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

2.Maven 的 pom.xml 配置以下,而後 maven 方式啓動運行mysql

<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

3.maven 方式啓動詳見配置以下:web

4.不出意外就能夠運行了spring

相關文章
相關標籤/搜索