Maven+Mybatis+Spring配置之第一步:配置pom.xml依賴
阿新 • • 發佈:2019-02-18
1.配置slfj+logback:
Java程式碼
- <!-- Logging -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${org.slf4j.version}</version>
- </dependency>
-
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- <version>${org.slf4j.version}</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
-
<groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>${org.slf4j.version}</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
-
<artifactId>log4j</artifactId>
- <version>1.2.15</version>
- <exclusions>
- <exclusion>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.jms</groupId>
- <artifactId>jms</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.sun.jdmk</groupId>
- <artifactId>jmxtools</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.sun.jmx</groupId>
- <artifactId>jmxri</artifactId>
- </exclusion>
- </exclusions>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>${logback.version}</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- <version>${logback.version}</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- <version>${org.slf4j.version}</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>log4j-over-slf4j</artifactId>
- <version>${org.slf4j.version}</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jul-to-slf4j</artifactId>
- <version>${org.slf4j.version}</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${org.slf4j.version}</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
2.Spring配置:
Java程式碼
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webmvc</artifactId>
- <version>${org.springframework.version}</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${org.springframework.version}</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
3.Mybatis配置:
Java程式碼
- <dependency>
- <groupId>org.mybatis</groupId>
- <artifactId>mybatis</artifactId>
- <version>3.0.5-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.mybatis</groupId>
- <artifactId>mybatis-spring</artifactId>
- <version>1.0.0</version>
- </dependency>
另外還需要給mybatis加一個repository:
Java程式碼
- <repository>
- <id>mybatis-snapshot</id>
- <name>MyBatis Snapshot Repository</name>
- <url>https://oss.sonatype.org/content/repositories/snapshots</url>
- </repository>
4.BoneCP資料來源的依賴
Java程式碼
- <dependency>
- <groupId>com.jolbox</groupId>
- <artifactId>bonecp</artifactId>
- <version>0.7.1-rc2</version>
- </dependency>
- <dependency>
- <groupId>com.jolbox</groupId>
- <artifactId>bonecp-provider</artifactId>
- <version>0.7.1-rc2</version>
- </dependency>
- <dependency>
- <groupId>com.jolbox</groupId>
- <artifactId>bonecp-spring</artifactId>
- <version>0.7.1-rc2</version>
- </dependency>
還需要給BoneCP加一個repostory:
Java程式碼
- <repository>
- <releases>
- <enabled>true</enabled>
- </releases>
- <id>bonecp-repo</id>
- <name>BoneCP Repository</name>
- <url>http://jolbox.com/bonecp/downloads/maven</url>
- </repository>