MyBatis整合Spring详细教程
1整合思路
1、SqlSessionFactory对象应该放到spring容器中作为单例存在。
2、传统dao的开发方式中,应该从spring容器中获得sqlsession对象。
3、Mapper代理形式中,应该从spring容器中直接获得mapper的代理对象。
4、数据库的连接以及数据库连接池事务管理都交给spring容器来完成。
2 需要整合的jar包
1、spring的jar包
2、Mybatis的jar包
3、Spring+mybatis的整合包。
4、Mysql的数据库驱动jar包。
5、数据库连接池的jar包。
3 整合步骤
1.创建java工程
2.导入jar包
3.加入配置文件
1 SqlMapConfig.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- 设置别名 -->
<typeAliases>
<!-- 2. 指定扫描包,会把包内所有的类都设置别名,别名的名称就是类名,大小写不敏感 -->
<package name="com.mybatis.spring.pojo" />
</typeAliases> </configuration>
2 applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-4.0.xsd"> <!-- 1加载配置文件 -->
<context:property-placeholder location="classpath:db.properties" /> <!-- 2配置连接池 -->
<bean name="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="maxActive" value="10" />
<property name="maxIdle" value="5" />
</bean> <!--3 配置SqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 配置mybatis核心配置文件 -->
<property name="configLocation" value="classpath:SqlMapConfig.xml" />
<!-- 配置数据源 -->
<property name="dataSource" ref="dataSource" />
</bean> </beans>
3.db.properties
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://39.105.93.154:3306/mybatis?characterEncoding=utf-8
jdbc.username=tom
jdbc.password=tom
4.log4j.properties
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.err
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### direct messages to file mylog.log ###
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=d:\\mylog.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### set log levels - for more verbose logging change 'info' to 'debug' ###
### fatal error warn info debug trace \u5982\u679C\u4E0D\u60F3\u8981\u8F93\u51FA\uFF1B log4j.rootLogger=off, stdout
log4j.rootLogger=debug, stdout
效果
4原始dao的开发方式
原始的DAO开发接口+实现类来完成。
需要dao实现类需要继承SqlsessionDaoSupport类
1需求
- 实现根据用户id查询
- 实现根据用户名模糊查询
- 添加用户
2.创建pojo
package com.mybatis.spring.pojo; import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Set; public class User implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private String username;// 用户姓名
private Character sex;// 性别
private Date birthday;// 生日
private String address;// 地址 public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public Character getSex() {
return sex;
}
public void setSex(Character sex) {
this.sex = sex;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
@Override
public String toString() {
return "User [id=" + id + ", username=" + username + ", sex=" + sex + ", birthday=" + birthday + ", address="
+ address + "]";
}
}
3.实现Mapper.xml
编写User.xml配置文件,如下.
这里要注意的是<mapper namespace="test"> 中的 namespace="test" 一定不能掉。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="test">
<!-- 实现根据用户id查询 -->
<select id="queryUserById" parameterType="Integer" resultType="User">
select * from user where id = #{id}
</select> <!-- 实现根据用户名模糊查询 -->
<select id="queryUserByUsername" parameterType="String" resultType="User">
select * from user where username like '%${value}%'
</select> <!-- 添加用户 -->
<insert id="saveUser" parameterType="User">
<selectKey keyColumn="id" keyProperty="id" resultType="int" order="AFTER">
select last_insert_id()
</selectKey>
insert into user
(username,birthday,sex,address)
values
(#{username},#{birthday},#{sex},#{address})
</insert>
</mapper>
如果<mapper namespace="test"> 中的 namespace="test" 没有的话,会报下面的异常。
16:56:25,919 WARN ClassPathXmlApplicationContext:487 - Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [SqlMapConfig.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:743)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.mybatis.spring.junit.UserDaoImplTest.setUp(UserDaoImplTest.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [SqlMapConfig.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.NullPointerException
at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:434)
at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:340)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562)
... 35 more
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.NullPointerException
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:109)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:92)
at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:428)
... 38 more
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.NullPointerException
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:120)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:92)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:322)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:107)
... 40 more
Caused by: java.lang.NullPointerException
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:109)
... 43 more
16:56:25,921 DEBUG DefaultListableBeanFactory:512 - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@4098b95b: defining beans [org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0,dataSource,sqlSessionFactory,userDao]; root of factory hierarchy
4.加载Mapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- 设置别名 -->
<typeAliases>
<!-- 2. 指定扫描包,会把包内所有的类都设置别名,别名的名称就是类名,大小写不敏感 -->
<package name="com.mybatis.spring.pojo" />
</typeAliases> <mappers>
<mapper resource="sqlmap/User.xml"/> <package name="com.mybatis.spring.mapper"/>
</mappers>
</configuration>
5.实现IUserDao接口
package com.mybatis.spring.dao; import java.util.List; import com.mybatis.spring.pojo.User; public interface IUserDao { public abstract User queryUserById(Integer id);
public abstract List<User> queryUserByUsername(String username);
public abstract void saveUser(User user);
}
6.实现UserDaoImpl实现类
package com.mybatis.spring.dao.impl; import java.util.List; import org.mybatis.spring.support.SqlSessionDaoSupport; import com.mybatis.spring.dao.IUserDao;
import com.mybatis.spring.pojo.User; public class UserDaoImpl extends SqlSessionDaoSupport implements IUserDao { /**
* 根据id查询用户
*/
@Override
public User queryUserById(Integer id) {
User user = super.getSqlSession().selectOne("queryUserById", id);
// 不要关闭sqlSession
return user;
} /**
* 根据用户名模糊查询用户
*/
@Override
public List<User> queryUserByUsername(String username) {
return getSqlSession().selectList("queryUserByUsername", "张");
// 不要关闭sqlSession
} /**
* 保存用户
*/
@Override
public void saveUser(User user) {
getSqlSession().insert("saveUser",user);
// 不要关闭sqlSession
} }
7.在applicationContext.xml中配置dao
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-4.0.xsd"> <!-- 1加载配置文件 -->
<context:property-placeholder location="classpath:db.properties" /> <!-- 2配置连接池 -->
<bean name="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="maxActive" value="10" />
<property name="maxIdle" value="5" />
</bean> <!--3 配置SqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 配置mybatis核心配置文件 -->
<property name="configLocation" value="classpath:SqlMapConfig.xml" />
<!-- 配置数据源 -->
<property name="dataSource" ref="dataSource" />
</bean> <!-- 原始开发方式中,配置dao到spring中 -->
<bean name="userDao" class="com.mybatis.spring.dao.impl.UserDaoImpl">
<!-- 注入SqlSessionFatory -->
<property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
</bean> </beans>
8.测试方法
package com.mybatis.spring.junit; import java.util.Date;
import java.util.List; import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; import com.mybatis.spring.dao.IUserDao;
import com.mybatis.spring.pojo.User; public class UserDaoImplTest { private ApplicationContext ac;
@Before
public void setUp() throws Exception {
this.ac = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
} @Test
public void testQueryUserById() {
IUserDao userDao = ac.getBean(IUserDao.class);
User user = userDao.queryUserById(25);
System.out.println(user);
} @Test
public void testQueryUserByUsername() {
IUserDao userDao = ac.getBean(IUserDao.class);
List<User> list = userDao.queryUserByUsername("小");
for (User user : list) {
System.out.println(user);
}
} @Test
public void testSaveUser() {
IUserDao userDao = ac.getBean(IUserDao.class);
User user = new User();
user.setUsername("bobo");
user.setBirthday(new Date());
user.setSex('1');
user.setAddress("湖南");
userDao.saveUser(user);
System.out.println(user);
}
}
5.Mapper代理形式开发dao
a) 直接配置Mapper代理
b) 使用扫描包配置Mapper代理
需求:
- 实现根据用户id查询
- 实现根据用户名模糊查询
- 添加用户
1 实现Mapper.xml
编写UserMapper.xml配置文件,如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mybatis.spring.mapper.IUserMapper">
<!-- 实现根据用户id查询 -->
<select id="queryUserById" parameterType="Integer" resultType="User">
select * from user where id = #{id}
</select> <!-- 实现根据用户名模糊查询 -->
<select id="queryUserByUsername" parameterType="String" resultType="User">
select * from user where username like '%${value}%'
</select> <!-- 添加用户 -->
<insert id="saveUser" parameterType="User">
<selectKey keyColumn="id" keyProperty="id" resultType="int" order="AFTER">
select last_insert_id()
</selectKey>
insert into user
(username,birthday,sex,address)
values
(#{username},#{birthday},#{sex},#{address})
</insert>
</mapper>
2.实现UserMapper接口
package com.mybatis.spring.mapper; import java.util.List; import com.mybatis.spring.pojo.User; public interface IUserMapper { public abstract User queryUserById(Integer id);
public abstract List<User> queryUserByUsername(String username);
public abstract void saveUser(User user);
}
3.在applicationContext.xml配置mapper代理-方式一
4 测试程序
package com.mybatis.spring.junit; import java.util.Date;
import java.util.List; import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; import com.mybatis.spring.dao.IUserDao;
import com.mybatis.spring.mapper.IUserMapper;
import com.mybatis.spring.pojo.User; public class IUserMapperTest { private ApplicationContext ac; @Before
public void setUp() throws Exception {
this.ac = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
} @Test
public void testQueryUserById() {
IUserMapper userMapper = ac.getBean(IUserMapper.class);
User user = userMapper.queryUserById(31);
System.out.println(user);
} @Test
public void testQueryUserByUsername() {
IUserMapper userMapper = ac.getBean(IUserMapper.class);
List<User> list = userMapper.queryUserByUsername("小");
for (User user : list) {
System.out.println(user);
}
} @Test
public void testSaveUser() {
IUserMapper userMapper = ac.getBean(IUserMapper.class);
User user = new User();
user.setUsername("youyou");
user.setBirthday(new Date());
user.setSex('1');
user.setAddress("江苏");
userMapper.saveUser(user);
System.out.println(user);
}
}
5.在applicationContext.xml中配置mapper代理方式二
MyBatis整合Spring详细教程的更多相关文章
- Mybatis整合spring详细教程(适合小白童鞋)
目录 1.整合思路 2.整合需要的jar包 3.整合的步骤 4.Dao的开发的两种实现方式 6.Dao的开发的实现方式总结图 @ Mybatis整合spring其实就是SSM框架中SM的整合集成. 1 ...
- Struts2+Spring4+Hibernate4整合超详细教程
Struts2.Spring4.Hibernate4整合 超详细教程 Struts2.Spring4.Hibernate4整合实例-下载 项目目的: 整合使用最新版本的三大框架(即Struts2.Sp ...
- JAVAEE——Mybatis第二天:输入和输出映射、动态sql、关联查询、Mybatis整合spring、Mybatis逆向工程
1. 学习计划 1.输入映射和输出映射 a) 输入参数映射 b) 返回值映射 2.动态sql a) If标签 b) Where标签 c) Sql片段 d) Foreach标签 3.关联查询 a) 一对 ...
- mybatis整合spring 之 基于接口映射的多对一关系
转载自:http://my.oschina.net/huangcongmin12/blog/83731 mybatis整合spring 之 基于接口映射的多对一关系. 项目用到俩个表,即studen ...
- mybatis整合spring获取配置文件信息出错
描述:mybatis整合spring加载jdbc.properties文件,然后使用里面配置的值来 配置数据源,后来发现用户变成了admin- jdbc.properties的配置: 加载配置: 报错 ...
- Mybatis整合Spring -- typeAliasesPackage
Mybatis整合Spring 根据官方的说法,在ibatis3,也就是Mybatis3问世之前,Spring3的开发工作就已经完成了,所以Spring3中还是没有对Mybatis3的支持. 因此由M ...
- 160330、Mybatis整合Spring
转自csdn文章 http://haohaoxuexi.iteye.com/blog/1843309 Mybatis整合Spring 根据官方的说法,在ibatis3,也就是Mybatis3问世之前, ...
- (转)MyBatis框架的学习(六)——MyBatis整合Spring
http://blog.csdn.net/yerenyuan_pku/article/details/71904315 本文将手把手教你如何使用MyBatis整合Spring,这儿,我本人使用的MyB ...
- 不需要怎么修改配置的Mybatis整合Spring要点
首先对于Mybatis的主配置文件,只需要修改一处地方,将事务交给Spring管理,其它地方可以原封不动. <?xml version="1.0" encoding=&quo ...
随机推荐
- 第六周—Alpha阶段项目复审(五饭来了吗)
第六周--Alpha阶段项目复审(五饭来了吗) 以下部分排名只是个人观点: 小组 优点 缺点,bug报告 名次 中午吃啥队 较完整的团体结构,可提供给商家和用户 感觉界面再优化一下就很棒了 1 天冷记 ...
- linux 扩展权限
默认权限 每一个终端都拥有一个umask属性,来确定新建文件,文件夹的默认权限 umask使用数字权限方式表示,如:022 新建目录的默认权限是:777-umask; 新建文件的默认权限是:6 ...
- Rabbimq必备基础之对高级消息队列协议AMQP分析及Rabbitmq本质介绍
MQ的一个产品... [消息队列] 1. MSMQ windows自带的一个服务... [petshop],message存放在文件系统中. 最原始的消息队列... [集群,消息确认,内存化,高可用, ...
- Thrift框架学习
参考文章:1.http://www.kankanews.com/ICkengine/archives/54084.shtml 2.http://www.cnblogs.com/liping135991 ...
- 反省在北京某S2B2C电商小型公司面试时掉链子的问题
昨天,参与北京一家公司面试时,不知道为什么,错了很多题,这些题在该家公司之前已经被问很多次了,当天精神恍惚的没答上来或答错,被问到数据库优化和乐观锁的问题,首先我谈到了存储引擎底层的数据结构 B树/B ...
- 一文读懂加固apk的开发者是怎么想的
有人说加固会明显拖慢启动速度,同时造成运行卡顿,严重降低用户体验,而且加固是完全可以脱壳的,只需要pc配合进行断点调试就能抓到解密后的dex文件,加固并没有所说的那么安全. 但是为什么还有一大批开发者 ...
- 「HNOI 2014」 画框
题目链接 戳我 \(Solution\) 这一题很像最小乘积生成树.只是把\(kruskal\)变为了\(km\)/费用流 现在来讲一讲最小乘积生成树.首先将\(\sum a_i\)和\(\sum b ...
- Mysql数据操作《三》多表查询
多表连接查询 复合条件连接查询 子查询 准备表 #建表 create table department( id int, name varchar(20) ); create table employ ...
- ocp题库变化,052新加的考试题及答案整理-32
32. Examine these commands and their output: • SQL> SELECT * FROM emp; • ENO ENAME • ---- ----- • ...
- “全栈2019”Java第三十八章:类与方法
难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java第 ...