码迷,mamicode.com
首页 > 编程语言 > 详细

springmvc mybatis maven 整合 事例

时间:2016-06-07 16:36:21      阅读:363      评论:0      收藏:0      [点我收藏+]

标签:springmvc mybatis maven 整合

最近做了个maven管理的springmvc+spring+mybatis,还用到了阿里巴巴的 fastjson和druid连接池,配置文件如下

pom.xml文件

[html] view plain copy 技术分享技术分享

  1. <?xml version="1.0" encoding="UTF-8"?>  

  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  

  3.     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">  

  4.     <modelVersion>4.0.0</modelVersion>  

  5.     <groupId>com.dahafo.demo</groupId>  

  6.     <name>um</name>  

  7.     <packaging>war</packaging>  

  8.     <version>1.0.0-BUILD-SNAPSHOT</version>  

  9.     <properties>  

  10.         <java-version>1.7</java-version>  

  11.         <org.springframework-version>3.2.3.RELEASE</org.springframework-version>  

  12.         <org.aspectj-version>1.6.10</org.aspectj-version>  

  13.         <org.slf4j-version>1.6.6</org.slf4j-version>  

  14.     </properties>  

  15.     <dependencies>  

  16.         <!-- Spring -->  

  17.         <dependency>  

  18.             <groupId>org.springframework</groupId>  

  19.             <artifactId>spring-context</artifactId>  

  20.             <version>${org.springframework-version}</version>  

  21.             <exclusions>  

  22.                 <!-- Exclude Commons Logging in favor of SLF4j -->  

  23.                 <exclusion>  

  24.                     <groupId>commons-logging</groupId>  

  25.                     <artifactId>commons-logging</artifactId>  

  26.                  </exclusion>  

  27.             </exclusions>  

  28.         </dependency>  

  29.         <dependency>  

  30.             <groupId>org.springframework</groupId>  

  31.             <artifactId>spring-webmvc</artifactId>  

  32.             <version>${org.springframework-version}</version>  

  33.         </dependency>  

  34.         <dependency>  

  35.             <groupId>org.springframework</groupId>  

  36.             <artifactId>spring-jdbc</artifactId>  

  37.             <version>${org.springframework-version}</version>  

  38.         </dependency>  

  39.                   

  40.         <!-- AspectJ -->  

  41.         <dependency>  

  42.             <groupId>org.aspectj</groupId>  

  43.             <artifactId>aspectjrt</artifactId>  

  44.             <version>${org.aspectj-version}</version>  

  45.         </dependency>   

  46.           

  47.         <!-- Logging -->  

  48.         <dependency>  

  49.             <groupId>org.slf4j</groupId>  

  50.             <artifactId>slf4j-api</artifactId>  

  51.             <version>${org.slf4j-version}</version>  

  52.         </dependency>  

  53.         <dependency>  

  54.             <groupId>org.slf4j</groupId>  

  55.             <artifactId>jcl-over-slf4j</artifactId>  

  56.             <version>${org.slf4j-version}</version>  

  57.             <scope>runtime</scope>  

  58.         </dependency>  

  59.         <dependency>  

  60.             <groupId>org.slf4j</groupId>  

  61.             <artifactId>slf4j-log4j12</artifactId>  

  62.             <version>${org.slf4j-version}</version>  

  63.             <scope>runtime</scope>  

  64.         </dependency>  

  65.         <dependency>  

  66.             <groupId>log4j</groupId>  

  67.             <artifactId>log4j</artifactId>  

  68.             <version>1.2.15</version>  

  69.             <exclusions>  

  70.                 <exclusion>  

  71.                     <groupId>javax.mail</groupId>  

  72.                     <artifactId>mail</artifactId>  

  73.                 </exclusion>  

  74.                 <exclusion>  

  75.                     <groupId>javax.jms</groupId>  

  76.                     <artifactId>jms</artifactId>  

  77.                 </exclusion>  

  78.                 <exclusion>  

  79.                     <groupId>com.sun.jdmk</groupId>  

  80.                     <artifactId>jmxtools</artifactId>  

  81.                 </exclusion>  

  82.                 <exclusion>  

  83.                     <groupId>com.sun.jmx</groupId>  

  84.                     <artifactId>jmxri</artifactId>  

  85.                 </exclusion>  

  86.             </exclusions>  

  87.             <scope>runtime</scope>  

  88.         </dependency>  

  89.   

  90.         <!-- @Inject -->  

  91.         <dependency>  

  92.             <groupId>javax.inject</groupId>  

  93.             <artifactId>javax.inject</artifactId>  

  94.             <version>1</version>  

  95.         </dependency>  

  96.                   

  97.         <!-- Servlet -->  

  98.         <dependency>  

  99.             <groupId>javax.servlet</groupId>  

  100.             <artifactId>servlet-api</artifactId>  

  101.             <version>2.5</version>  

  102.             <scope>provided</scope>  

  103.         </dependency>  

  104.         <dependency>  

  105.             <groupId>javax.servlet.jsp</groupId>  

  106.             <artifactId>jsp-api</artifactId>  

  107.             <version>2.1</version>  

  108.             <scope>provided</scope>  

  109.         </dependency>  

  110.         <dependency>  

  111.             <groupId>javax.servlet</groupId>  

  112.             <artifactId>jstl</artifactId>  

  113.             <version>1.2</version>  

  114.         </dependency>  

  115.     <!-- mybatis -->  

  116.         <dependency>  

  117.             <groupId>org.mybatis</groupId>  

  118.             <artifactId>mybatis</artifactId>  

  119.             <version>3.2.1</version>  

  120.         </dependency>  

  121.         <dependency>  

  122.             <groupId>org.mybatis</groupId>  

  123.             <artifactId>mybatis-spring</artifactId>  

  124.             <version>1.2.0</version>  

  125.         </dependency>  

  126.         <dependency>  

  127.             <groupId>mysql</groupId>  

  128.             <artifactId>mysql-connector-java</artifactId>  

  129.             <version>5.1.26</version>  

  130.         </dependency>  

  131.           

  132.           

  133.           

  134.         <!-- Test -->  

  135.         <dependency>  

  136.             <groupId>junit</groupId>  

  137.             <artifactId>junit</artifactId>  

  138.             <version>4.7</version>  

  139.             <scope>test</scope>  

  140.         </dependency>  

  141.         <dependency>  

  142.             <groupId>com.alibaba</groupId>  

  143.             <artifactId>druid</artifactId>  

  144.             <version>0.2.20</version>  

  145.         </dependency>  

  146.   

  147.         <dependency>  

  148.             <groupId>org.aspectj</groupId>  

  149.             <artifactId>aspectjweaver</artifactId>  

  150.             <version>1.7.2</version>  

  151.         </dependency>  

  152.         <dependency>  

  153.             <groupId>com.alibaba</groupId>  

  154.             <artifactId>fastjson</artifactId>  

  155.             <version>1.1.34</version>  

  156.         </dependency>  

  157.         <dependency>  

  158.             <groupId>com.fasterxml.jackson.core</groupId>  

  159.             <artifactId>jackson-core</artifactId>  

  160.             <version>2.2.2</version>  

  161.         </dependency>  

  162.         <dependency>  

  163.             <groupId>com.fasterxml.jackson.core</groupId>  

  164.             <artifactId>jackson-databind</artifactId>  

  165.             <version>2.2.2</version>  

  166.         </dependency>  

  167.         <dependency>  

  168.             <groupId>commons-fileupload</groupId>  

  169.             <artifactId>commons-fileupload</artifactId>  

  170.             <version>1.2.2</version>  

  171.         </dependency>  

  172.     </dependencies>  

  173.       

  174.       

  175.          

  176.     <build>  

  177.         <plugins>  

  178.             <plugin>  

  179.                 <artifactId>maven-eclipse-plugin</artifactId>  

  180.                 <version>2.9</version>  

  181.                 <configuration>  

  182.                     <additionalProjectnatures>  

  183.                         <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>  

  184.                     </additionalProjectnatures>  

  185.                     <additionalBuildcommands>  

  186.                         <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>  

  187.                     </additionalBuildcommands>  

  188.                     <downloadSources>true</downloadSources>  

  189.                     <downloadJavadocs>true</downloadJavadocs>  

  190.                 </configuration>  

  191.             </plugin>  

  192.             <plugin>  

  193.                 <groupId>org.apache.maven.plugins</groupId>  

  194.                 <artifactId>maven-compiler-plugin</artifactId>  

  195.                 <version>2.5.1</version>  

  196.                 <configuration>  

  197.                     <source>1.6</source>  

  198.                     <target>1.6</target>  

  199.                     <compilerArgument>-Xlint:all</compilerArgument>  

  200.                     <showWarnings>true</showWarnings>  

  201.                     <showDeprecation>true</showDeprecation>  

  202.                 </configuration>  

  203.             </plugin>  

  204.             <plugin>  

  205.                 <groupId>org.codehaus.mojo</groupId>  

  206.                 <artifactId>exec-maven-plugin</artifactId>  

  207.                 <version>1.2.1</version>  

  208.                 <configuration>  

  209.                     <mainClass>org.test.int1.Main</mainClass>  

  210.                 </configuration>  

  211.             </plugin>  

  212.         </plugins>  

  213.     </build>  

  214.     <artifactId>demo-um</artifactId>  

  215. </project>  


web.xml



[html] view plain copy 技术分享技术分享

  1. <?xml version="1.0" encoding="UTF-8"?>  

  2. <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"  

  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  

  4.     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">  

  5.   

  6.   

  7.   

  8.     <!-- The definition of the Root Spring Container shared by all Servlets and Filters -->  

  9.     <context-param>  

  10.         <param-name>contextConfigLocation</param-name>  

  11.         <param-value>/WEB-INF/spring/root-context.xml</param-value>  

  12.     </context-param>  

  13.     <!-- 用spring Encoding,解决乱码问题 -->  

  14.     <filter>      

  15.             <filter-name>encodingFilter</filter-name>      

  16.             <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>      

  17.             <init-param>      

  18.                 <param-name>encoding</param-name>      

  19.                 <param-value>UTF-8</param-value>      

  20.             </init-param>      

  21.             <init-param>      

  22.                 <param-name>forceEncoding</param-name>      

  23.                 <param-value>true</param-value>      

  24.             </init-param>      

  25.         </filter>      

  26.          <filter-mapping>      

  27.             <filter-name>encodingFilter</filter-name>      

  28.             <url-pattern>/*</url-pattern>      

  29.         </filter-mapping>   

  30.     <!-- Creates the Spring Container shared by all Servlets and Filters -->  

  31.     <listener>  

  32.         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  

  33.     </listener>  



springmvc mybatis maven 整合 事例

标签:springmvc mybatis maven 整合

原文地址:http://11701009.blog.51cto.com/11691009/1786928

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!