1. 程式人生 > >Maven+Mybatis+Spring配置之第一步:配置pom.xml依賴

Maven+Mybatis+Spring配置之第一步:配置pom.xml依賴


1.配置slfj+logback: 
Java程式碼  收藏程式碼
  1. <!-- Logging -->  
  2.         <dependency>  
  3.             <groupId>org.slf4j</groupId>  
  4.             <artifactId>slf4j-api</artifactId>  
  5.             <version>${org.slf4j.version}</version>  
  6.         </dependency>  
  7.         <dependency>  
  8.             <groupId>org.slf4j</groupId>  
  9.             <artifactId>jcl-over-slf4j</artifactId>  
  10.             <version>${org.slf4j.version}</version>  
  11.             <scope>runtime</scope>  
  12.         </dependency>  
  13.         <dependency>  
  14.             <groupId>org.slf4j</groupId>  
  15.             <artifactId>slf4j-log4j12</artifactId>  
  16.             <version>${org.slf4j.version}</version>  
  17.             <scope>runtime</scope>  
  18.         </dependency>  
  19.         <dependency>  
  20.             <groupId>log4j</groupId>  
  21.             <artifactId>log4j</artifactId>  
  22.             <version>1.2.15</version>  
  23.             <exclusions>  
  24.                 <exclusion>  
  25.                     <groupId>javax.mail</groupId>  
  26.                     <artifactId>mail</artifactId>  
  27.                 </exclusion>  
  28.                 <exclusion>  
  29.                     <groupId>javax.jms</groupId>  
  30.                     <artifactId>jms</artifactId>  
  31.                 </exclusion>  
  32.                 <exclusion>  
  33.                     <groupId>com.sun.jdmk</groupId>  
  34.                     <artifactId>jmxtools</artifactId>  
  35.                 </exclusion>  
  36.                 <exclusion>  
  37.                     <groupId>com.sun.jmx</groupId>  
  38.                     <artifactId>jmxri</artifactId>  
  39.                 </exclusion>  
  40.             </exclusions>  
  41.             <scope>runtime</scope>  
  42.         </dependency>  
  43.         <dependency>  
  44.             <groupId>ch.qos.logback</groupId>  
  45.             <artifactId>logback-classic</artifactId>  
  46.             <version>${logback.version}</version>  
  47.             <type>jar</type>  
  48.             <scope>compile</scope>  
  49.         </dependency>  
  50.         <dependency>  
  51.             <groupId>ch.qos.logback</groupId>  
  52.             <artifactId>logback-core</artifactId>  
  53.             <version>${logback.version}</version>  
  54.             <type>jar</type>  
  55.             <scope>compile</scope>  
  56.         </dependency>  
  57.         <dependency>  
  58.             <groupId>org.slf4j</groupId>  
  59.             <artifactId>jcl-over-slf4j</artifactId>  
  60.             <version>${org.slf4j.version}</version>  
  61.             <type>jar</type>  
  62.             <scope>compile</scope>  
  63.         </dependency>  
  64.         <dependency>  
  65.             <groupId>org.slf4j</groupId>  
  66.             <artifactId>log4j-over-slf4j</artifactId>  
  67.             <version>${org.slf4j.version}</version>  
  68.             <type>jar</type>  
  69.             <scope>compile</scope>  
  70.         </dependency>  
  71.         <dependency>  
  72.             <groupId>org.slf4j</groupId>  
  73.             <artifactId>jul-to-slf4j</artifactId>  
  74.             <version>${org.slf4j.version}</version>  
  75.             <type>jar</type>  
  76.             <scope>compile</scope>  
  77.         </dependency>  
  78.         <dependency>  
  79.             <groupId>org.slf4j</groupId>  
  80.             <artifactId>slf4j-api</artifactId>  
  81.             <version>${org.slf4j.version}</version>  
  82.             <type>jar</type>  
  83.             <scope>compile</scope>  
  84.         </dependency>  


2.Spring配置: 
Java程式碼  收藏程式碼
  1. <dependency>  
  2.             <groupId>org.springframework</groupId>  
  3.             <artifactId>spring-webmvc</artifactId>  
  4.             <version>${org.springframework.version}</version>  
  5.             <type>jar</type>  
  6.             <scope>compile</scope>  
  7.         </dependency>  
  8.         <dependency>  
  9.             <groupId>org.springframework</groupId>  
  10.             <artifactId>spring-context</artifactId>  
  11.             <version>${org.springframework.version}</version>  
  12.             <type>jar</type>  
  13.             <scope>compile</scope>  
  14.         </dependency>  


3.Mybatis配置: 
Java程式碼  收藏程式碼
  1. <dependency>  
  2.             <groupId>org.mybatis</groupId>  
  3.             <artifactId>mybatis</artifactId>  
  4.             <version>3.0.5-SNAPSHOT</version>  
  5.         </dependency>  
  6.         <dependency>  
  7.             <groupId>org.mybatis</groupId>  
  8.             <artifactId>mybatis-spring</artifactId>  
  9.             <version>1.0.0</version>  
  10.         </dependency>  

另外還需要給mybatis加一個repository: 
Java程式碼  收藏程式碼
  1. <repository>  
  2.             <id>mybatis-snapshot</id>  
  3.             <name>MyBatis Snapshot Repository</name>  
  4.             <url>https://oss.sonatype.org/content/repositories/snapshots</url>  
  5.         </repository>  

4.BoneCP資料來源的依賴 
Java程式碼  收藏程式碼
  1. <dependency>  
  2.             <groupId>com.jolbox</groupId>  
  3.             <artifactId>bonecp</artifactId>  
  4.             <version>0.7.1-rc2</version>  
  5.         </dependency>  
  6.         <dependency>  
  7.             <groupId>com.jolbox</groupId>  
  8.             <artifactId>bonecp-provider</artifactId>  
  9.             <version>0.7.1-rc2</version>  
  10.         </dependency>  
  11.         <dependency>  
  12.             <groupId>com.jolbox</groupId>  
  13.             <artifactId>bonecp-spring</artifactId>  
  14.             <version>0.7.1-rc2</version>  
  15.         </dependency>  

還需要給BoneCP加一個repostory: 
Java程式碼  收藏程式碼
  1. <repository>  
  2.             <releases>  
  3.                 <enabled>true</enabled>  
  4.             </releases>  
  5.             <id>bonecp-repo</id>  
  6.             <name>BoneCP Repository</name>  
  7.             <url>http://jolbox.com/bonecp/downloads/maven</url>  
  8.         </repository>