基于SSM框架配置多数据源

Posted ZT1994

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于SSM框架配置多数据源相关的知识,希望对你有一定的参考价值。

项目基于ssm + maven,通过注解可以实现自动切换数据源。

一、pom.xml

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 
  3 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5     <modelVersion>4.0.0</modelVersion>
  6     
  7     <groupId>com.multipleDataSource</groupId>
  8     <artifactId>multipleDataSource</artifactId>
  9     <version>1.0-SNAPSHOT</version>
 10     <packaging>war</packaging>
 11     
 12     <name>multipleDataSource Maven Webapp</name>
 13     <!-- FIXME change it to the project\'s website -->
 14     <url>http://www.example.com</url>
 15     
 16     <properties>
 17         <org.springframework.version>4.2.4.RELEASE</org.springframework.version>
 18         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 19         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
 20         <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
 21         <maven.compiler.source>1.7</maven.compiler.source>
 22         <maven.compiler.target>1.7</maven.compiler.target>
 23         <jackson.version>2.8.5</jackson.version>
 24     
 25         <org.mybatis.version>3.4.1</org.mybatis.version>
 26         <org.mybatis.spring.version>1.3.0</org.mybatis.spring.version>
 27     </properties>
 28     
 29     <dependencies>
 30         <dependency>
 31             <groupId>org.apache.tomcat</groupId>
 32             <artifactId>tomcat-servlet-api</artifactId>
 33             <version>7.0.64</version>
 34         </dependency>
 35     
 36         <dependency>
 37             <groupId>org.springframework</groupId>
 38             <artifactId>spring-core</artifactId>
 39             <version>${org.springframework.version}</version>
 40         </dependency>
 41     
 42         <dependency>
 43             <groupId>org.springframework</groupId>
 44             <artifactId>spring-expression</artifactId>
 45             <version>${org.springframework.version}</version>
 46         </dependency>
 47     
 48         <dependency>
 49             <groupId>org.springframework</groupId>
 50             <artifactId>spring-beans</artifactId>
 51             <version>${org.springframework.version}</version>
 52         </dependency>
 53     
 54         <dependency>
 55             <groupId>org.springframework</groupId>
 56             <artifactId>spring-aop</artifactId>
 57             <version>${org.springframework.version}</version>
 58         </dependency>
 59     
 60         <dependency>
 61             <groupId>org.springframework</groupId>
 62             <artifactId>spring-context</artifactId>
 63             <version>${org.springframework.version}</version>
 64         </dependency>
 65         
 66         <dependency>
 67             <groupId>org.springframework</groupId>
 68             <artifactId>spring-webmvc</artifactId>
 69             <version>${org.springframework.version}</version>
 70         </dependency>
 71     
 72         <dependency>
 73             <groupId>org.springframework</groupId>
 74             <artifactId>spring-oxm</artifactId>
 75             <version>${org.springframework.version}</version>
 76         </dependency>
 77     
 78         <dependency>
 79             <groupId>org.springframework</groupId>
 80             <artifactId>spring-jdbc</artifactId>
 81             <version>${org.springframework.version}</version>
 82         </dependency>
 83     
 84         <dependency>
 85             <groupId>org.springframework</groupId>
 86             <artifactId>spring-tx</artifactId>
 87             <version>${org.springframework.version}</version>
 88         </dependency>
 89     
 90         <dependency>
 91             <groupId>org.springframework</groupId>
 92             <artifactId>spring-web</artifactId>
 93             <version>${org.springframework.version}</version>
 94         </dependency>
 95     
 96         <dependency>
 97             <groupId>org.springframework</groupId>
 98             <artifactId>spring-test</artifactId>
 99             <version>${org.springframework.version}</version>
100         </dependency>
101     
102         <dependency>
103             <groupId>org.aspectj</groupId>
104             <artifactId>aspectjweaver</artifactId>
105             <version>1.7.3</version>
106         </dependency>
107     
108         <dependency>
109             <groupId>org.mybatis</groupId>
110             <artifactId>mybatis-spring</artifactId>
111             <version>${org.mybatis.spring.version}</version>
112         </dependency>
113         <dependency>
114             <groupId>org.mybatis</groupId>
115             <artifactId>mybatis</artifactId>
116             <version>${org.mybatis.version}</version>
117         </dependency>
118     
119         <dependency>
120             <groupId>org.aspectj</groupId>
121             <artifactId>aspectjrt</artifactId>
122             <version>1.6.11</version>
123         </dependency>
124     
125         <dependency>
126             <groupId>org.codehaus.jackson</groupId>
127             <artifactId>jackson-mapper-asl</artifactId>
128             <version>1.9.12</version>
129         </dependency>
130     
131         <dependency>
132             <groupId>commons-dbcp</groupId>
133             <artifactId>commons-dbcp</artifactId>
134             <version>1.4</version>
135             <!--<scope>runtime</scope>-->
136         </dependency>
137     
138         <dependency>
139             <groupId>ch.qos.logback</groupId>
140             <artifactId>logback-classic</artifactId>
141             <version>1.1.2</version>
142             <scope>compile</scope>
143         </dependency>
144         <dependency>
145             <groupId>ch.qos.logback</groupId>
146             <artifactId>logback-core</artifactId>
147             <version>1.1.2</version>
148             <scope>compile</scope>
149         </dependency>
150     
151         <dependency>
152             <groupId>mysql</groupId>
153             <artifactId>mysql-connector-java</artifactId>
154             <version>5.1.6</version>
155         </dependency>
156     
157         <dependency>
158             <groupId>com.google.guava</groupId>
159             <artifactId>guava</artifactId>
160             <version>20.0</version>
161         </dependency>
162     
163     
164         <dependency>
165             <groupId>org.apache.commons</groupId>
166             <artifactId>commons-lang3</artifactId>
167             <version>3.5</version>
168         </dependency>
169     
170     
171         <dependency>
172             <groupId>commons-collections</groupId>
173             <artifactId>commons-collections</artifactId>
174             <version>3.2.1</version>
175         </dependency>
176     
177         <dependency>
178             <groupId>com</groupId>
179             <artifactId>druid</artifactId>
180             <version>1.0.9</version>
181         </dependency>
182     
183         <dependency>
184             <groupId>javax.servlet</groupId>
185             <artifactId>jstl</artifactId>
186             <version>1.2</version>
187         </dependency>
188     
189         <dependency>
190             <groupId>taglibs</groupId>
191             <artifactId>standard</artifactId>
192             <version>1.1.2</version>
193         </dependency>
194         
195         <!-- jackson -->
196         <dependency>
197             <groupId>com.fasterxml.jackson.core</groupId>
198             <artifactId>jackson-core</artifactId>
199             <version>${jackson.version}</version>
200         </dependency>
201         <dependency>
202             <groupId>com.fasterxml.jackson.core</groupId>
203             <artifactId>jackson-databind</artifactId>
204             <version>${jackson.version}</version>
205         </dependency>
206         <dependency>
207             <groupId>com.fasterxml.jackson.core</groupId>
208             <artifactId>jackson-annotations</artifactId>
209             <version>${jackson.version}</version>
210         </dependency>
211     
212         
213         <dependency>
214             <groupId>junit</groupId>
215             <artifactId>junit</artifactId>
216             <version>4.11</version>
217             <scope>test</scope>
218         </dependency>
219     </dependencies>
220     
221     <build>
222         <finalName>multipleDataSource</finalName>
223         <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
224             <plugins>
225                 <plugin>
226                     <artifactId>maven-clean-plugin</artifactId>
227                     <基于SSM框架配置多数据源

基于 xml 配置文件的入门级 SSM 框架整合

一款基于SSM框架技术的全栈Java web项目(已部署可直接体验)

基于XML配置方式SSM框架西蒙购物网

ssm框架物资审批功能

SSM框架与SSH框架的比较