package com.msd.test;
import java.util.List;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.msd.entity.Student;
import com.msd.service.StudentService;
public class TestOO {
public static void main(String[] args) {
query();
//insert();
}
public static void query() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/spring/applicationContext.xml");
StudentService ss = (StudentService)ctx.getBean("studentService");
List<Student> lists = ss.query();
for(Student s : lists) {
System.out.println(s.getId() + "--->" + s.getName());
}
}
public static void insert() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/spring/applicationContext.xml");
StudentService ss = (StudentService)ctx.getBean("studentService");
ss.insert(new Student(22,"哈哈"));
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
MySQL Master Slave 集群构架和spring整合,里面实现的是动态切换数据源,大家都是知道,spring2之后添加AbstractRoutingDataSource这个东西,这个就可以实现切换数据源,实现思路是:先按照<<搭建MySQL的MasterSlave架构.doc>>(我上传有资源),搭建好,然后动态切换数据源的时候,利用aop,每次查询的时候,就取Slave的数据源,更新 删除 插入的时候取Master的数据源,这样就能实现动态切换,分数给的有点高,但是我上传的资源都是原创
资源推荐
资源详情
资源评论
收起资源包目录
MySQLMasterSlave.rar (66个子文件)
MySQLMasterSlave
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.project.facet.core.xml 252B
org.eclipse.wst.common.component 486B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 493B
org.eclipse.jdt.core.prefs 395B
src
mybatis_conf.xml 298B
log4j.properties 682B
com
msd
dao
StudentDao.java 190B
test
TestOO.java 913B
datasource
ChangeDataSource.java 483B
MyRoutingDataSource.java 297B
MyAfterAOPAdvice.java 789B
MybeforeAOPAdvice.java 546B
DataSourceHolder.java 906B
service
impl
StudentServiceImpl.java 734B
StudentService.java 197B
entity
Student.java 412B
mapper
student.xml 430B
spring
applicationContext_app.xml 1KB
applicationContext.xml 3KB
.project 2KB
WebRoot
META-INF
MANIFEST.MF 36B
WEB-INF
web.xml 634B
classes
mybatis_conf.xml 298B
log4j.properties 682B
com
msd
dao
StudentDao.class 264B
test
TestOO.class 2KB
datasource
MyRoutingDataSource.class 575B
DataSourceHolder.class 1KB
ChangeDataSource.class 554B
MybeforeAOPAdvice.class 1KB
MyAfterAOPAdvice.class 2KB
service
StudentService.class 276B
impl
StudentServiceImpl.class 1KB
entity
Student.class 847B
mapper
student.xml 430B
spring
applicationContext_app.xml 1KB
applicationContext.xml 3KB
lib
org.springframework.web.struts-3.0.5.RELEASE.jar 31KB
org.springframework.context-3.1.2.RELEASE.jar 813KB
mybatis-3.0.6.jar 630KB
org.springframework.instrument.tomcat-3.0.5.RELEASE.jar 6KB
org.springframework.jdbc-3.1.2.RELEASE.jar 395KB
log4j-1.2.16.jar 470KB
org.springframework.beans-3.1.2.RELEASE.jar 578KB
mybatis-spring-1.0.2-SNAPSHOT.jar 34KB
org.springframework.aop-3.1.2.RELEASE.jar 325KB
com.springsource.org.aopalliance-1.0.0.jar 5KB
mysql-connector-java-5.1.6-bin.jar 687KB
org.springframework.web.servlet-3.0.5.RELEASE.jar 409KB
org.springframework.orm-3.1.2.RELEASE.jar 371KB
org.springframework.core-3.1.2.RELEASE.jar 439KB
commons-logging.jar 52KB
org.springframework.web-3.1.2.RELEASE.jar 536KB
aspectjweaver.jar 1.82MB
org.springframework.asm-3.1.2.RELEASE.jar 52KB
cglib-nodep-2.1_3.jar 317KB
commons-dbcp-1.2.2.jar 119KB
org.springframework.web.portlet-3.0.5.RELEASE.jar 171KB
commons-pool.jar 61KB
org.springframework.expression-3.1.2.RELEASE.jar 172KB
org.springframework.transaction-3.1.2.RELEASE.jar 239KB
index.jsp 834B
.mymetadata 321B
.classpath 529B
.myeclipse
共 66 条
- 1
资源评论
- xz3423252222015-08-10还可以,就是感觉有点乱
- 王仕贵2016-03-23感觉没什么用!
limingxue438312413
- 粉丝: 2
- 资源: 35
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功