spring 整合 mybatis 中数据源的几种配置总结

2023-11-02

spring 整合 mybatis 中数据源的几种配置方式

因为spring 整合mybatis的过程中, 有好几种整合方式,尤其是数据源那块,经常看到不一样的配置方式,总感觉有点乱,所以今天有空总结下。

一、采用org.mybatis.spring.mapper.MapperScannerConfigurer

其实逆向工程也是这种方式

1、数据源配配置文件
复制代码

1 <?xml version="1.0" encoding="UTF-8"?>
2 <beans xmlns=“http://www.springframework.org/schema/beans”
3 xmlns:context=“http://www.springframework.org/schema/context” xmlns:p=“http://www.springframework.org/schema/p”
4 xmlns:aop=“http://www.springframework.org/schema/aop” xmlns:tx=“http://www.springframework.org/schema/tx”
5 xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
6 xsi:schemaLocation=“http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
7 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
8 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
9 http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd”>
10
11
12 <context:property-placeholder location=“classpath:resource/*.properties” />
13
14
15 <bean id=“dataSource” class=“com.alibaba.druid.pool.DruidDataSource”
16 destroy-method=“close”>
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

复制代码

2、DAO文件
复制代码

1 package com.jdd.mapper;
2
3 import com.jdd.pojo.Employee;
4 import java.util.List;
5
6 public interface EmployeeMapper {
7
8 public Employee getEmployeeById(int id);
9
10 public List findAllEmployees();
11
12 }

复制代码

3、Mapper.xml 文件
复制代码

1 <?xml version="1.0" encoding="UTF-8" ?>
2
4
5
6
7
8 <![CDATA[ 9 select * from employee where id = #{id}; 10 ]]>
11
12
13
14 <![CDATA[ 15 select * from employee where status='1'; 16 ]]>
17
18
19
20

复制代码

这样在service类里就可以直接注入dao接口了
复制代码

1 package com.jdd.service.impl;
2
3 import com.jdd.mapper.EmployeeMapper;
4 import com.jdd.pojo.Employee;
5 import com.jdd.service.EmployeeService;
6 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.stereotype.Service;
8 import java.util.List;
9
10 @Service(“employeeService”)
11 public class EmployeeServiceImpl implements EmployeeService{
12
13 @Autowired
14 private EmployeeMapper employeeMapper;
15
16 @Override
17 public Employee getEmployeeById(int id) {
18 return employeeMapper.getEmployeeById(id);
19 }
20
21 @Override
22 public List findAllEmployees() {
23 return employeeMapper.findAllEmployees();
24 }
25
26 }

复制代码

二、 采用抽象类org.mybatis.spring.support.SqlSessionDaoSupport, 给它注入 sqlSessionFactory的方式

1、数据源配置文件
复制代码

1 <?xml version="1.0" encoding="UTF-8"?>
2 <beans xmlns=“http://www.springframework.org/schema/beans”
3 xmlns:context=“http://www.springframework.org/schema/context” xmlns:p=“http://www.springframework.org/schema/p”
4 xmlns:aop=“http://www.springframework.org/schema/aop” xmlns:tx=“http://www.springframework.org/schema/tx”
5 xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
6 xsi:schemaLocation=“http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
7 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
8 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
9 http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd”>
10
11
12 <context:property-placeholder location=“classpath:resource/*.properties” />
13
14
15 <bean id=“dataSource” class=“com.alibaba.druid.pool.DruidDataSource”
16 destroy-method=“close”>
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
34

复制代码

2、baseDao类
复制代码

1 package com.hd.dao;
2
3 import org.apache.ibatis.session.SqlSessionFactory;
4 import org.mybatis.spring.support.SqlSessionDaoSupport;
5 import javax.annotation.Resource;
6
7 public abstract class BaseDao extends SqlSessionDaoSupport {
8
9 @Resource
10 public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
11 super.setSqlSessionFactory(sqlSessionFactory);
12 }
13
14 }

复制代码

3、接口 EmployeeDao.java 类
复制代码

1 package com.hd.dao;
2
3 import com.hd.pojo.Employee;
4
5 import java.util.List;
6
7 public interface EmployeeDao {
8
9 Employee getEmployeeById(int id);
10
11 List findAllEmployees();
12
13 }

复制代码

4、dao实现类 EmployeeDaoImpl
复制代码

1 package com.hd.dao.impl;
2
3 import com.hd.dao.BaseDao;
4 import com.hd.dao.EmployeeDao;
5 import com.hd.pojo.Employee;
6 import org.springframework.stereotype.Repository;
7 import java.util.List;
8
9 @Repository(“employeeDao”)
10 public class EmployeeDaoImpl extends BaseDao implements EmployeeDao {
11
12 @Override
13 public Employee getEmployeeById(int id) {
14 return this.getSqlSession().selectOne(“com.jdd.dao.EmployeeDao.getEmployeeById”, id);
15 }
16
17 @Override
18 public List findAllEmployees() {
19 return this.getSqlSession().selectList(“com.jdd.dao.EmployeeDao.findAllEmployees”);
20 }
21
22
23 }

复制代码

5、这样就可以在service类里注入 employeeDao了

三、采用 org.mybatis.spring.SqlSessionTemplate 模板类

1、数据源文件
复制代码

1 <?xml version="1.0" encoding="UTF-8"?>
2 <beans xmlns=“http://www.springframework.org/schema/beans”
3 xmlns:context=“http://www.springframework.org/schema/context” xmlns:p=“http://www.springframework.org/schema/p”
4 xmlns:aop=“http://www.springframework.org/schema/aop” xmlns:tx=“http://www.springframework.org/schema/tx”
5 xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
6 xsi:schemaLocation=“http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
7 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
8 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
9 http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd”>
10
11
12 <context:property-placeholder location=“classpath:resource/*.properties” />
13
14
15 <bean id=“dataSource” class=“com.alibaba.druid.pool.DruidDataSource”
16 destroy-method=“close”>
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

复制代码

2、 basedao.java 类
复制代码

1 package com.hd.dao;
2
3 import org.mybatis.spring.SqlSessionTemplate;
4 import javax.annotation.Resource;
5
6 public abstract class BaseDao {
7
8 public SqlSessionTemplate sqlSessionTemplate;
9 @Resource
10 public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
11 this.sqlSessionTemplate = sqlSessionTemplate;
12 }
13 }

复制代码

3、接口 EmployeeDao.java 类
复制代码

1 package com.hd.dao;
2
3 import com.hd.pojo.Employee;
5 import java.util.List;
6
7 public interface EmployeeDao {
8
9 Employee getEmployeeById(int id);
10
11 List findAllEmployees();
12 }

复制代码

4、dao实现类 EmployeeDaoImpl
复制代码

1 package com.hd.dao.impl;
2
3 import com.hd.dao.BaseDao;
4 import com.hd.dao.EmployeeDao;
5 import com.hd.pojo.Employee;
6 import org.springframework.stereotype.Repository;
7 import java.util.List;
8
9 @Repository(“employeeDao”)
10 public class EmployeeDaoImpl extends BaseDao implements EmployeeDao {
11
12 @Override
13 public Employee getEmployeeById(int id) {
14 return sqlSessionTemplate.selectOne(“com.jdd.dao.EmployeeDao.getEmployeeById”, id);
15 }
16
17 @Override
18 public List findAllEmployees() {
19 return sqlSessionTemplate.selectList(“com.jdd.dao.EmployeeDao.findAllEmployees”);
20 }
21
22
23 }

复制代码

5、同样现在也可以在service类里直接注入 employeeDao使用了。

注:这里basedao的注入比较灵活,也可以注入 SqlSessionFactory, 然后再setter方法里创建 SqlSessionTemplate,如下:
复制代码

1 package com.hd.dao;
2
3 import org.apache.ibatis.session.SqlSessionFactory;
4 import org.mybatis.spring.SqlSessionTemplate;
5
6 import javax.annotation.Resource;
7
8 public abstract class BaseDao {
9
10 public SqlSessionTemplate sqlSessionTemplate;
11 @Resource
12 public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
13 sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory);
14 }
15
16 }

复制代码

其实不管是采用 继承SqlSessionDaoSupport类, 注入 sqlSessionFactory的方式, 还是直接注入 SqlSessionTemplate 的方式, 本质上是一样的。

如果你采用 注入 sqlSessionFactory的方式, 它在底层也是通过sqlSessionFactory 来创建 SqlSessionTemplate ,然后通过其api来操作。

不信给你们看下 SqlSessionDaoSupport 的源码:
复制代码

1 //
2 // Source code recreated from a .class file by IntelliJ IDEA
3 // (powered by Fernflower decompiler)
4 //
5
6 package org.mybatis.spring.support;
7
8 import org.apache.ibatis.session.SqlSession;
9 import org.apache.ibatis.session.SqlSessionFactory;
10 import org.mybatis.spring.SqlSessionTemplate;
11 import org.springframework.dao.support.DaoSupport;
12 import org.springframework.util.Assert;
13
14 public abstract class SqlSessionDaoSupport extends DaoSupport {
15 private SqlSession sqlSession;
16 private boolean externalSqlSession;
17
18 public SqlSessionDaoSupport() {
19 }
20
21 public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
22 if (!this.externalSqlSession) {
23 this.sqlSession = new SqlSessionTemplate(sqlSessionFactory);
24 }
25
26 }
27
28 public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
29 this.sqlSession = sqlSessionTemplate;
30 this.externalSqlSession = true;
31 }
32
33 public SqlSession getSqlSession() {
34 return this.sqlSession;
35 }
36
37 protected void checkDaoConfig() {
38 Assert.notNull(this.sqlSession, “Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required”);
39 }
40 }

复制代码

同样 SqlSessionTemplate 继承了 SqlSession 接口, 因此不管操作哪个效果都一样
复制代码

1 //
2 // Source code recreated from a .class file by IntelliJ IDEA
3 // (powered by Fernflower decompiler)
4 //
5
6 package org.mybatis.spring;
7
8 import java.lang.reflect.InvocationHandler;
9 import java.lang.reflect.Method;
10 import java.lang.reflect.Proxy;
11 import java.sql.Connection;
12 import java.util.List;
13 import java.util.Map;
14 import org.apache.ibatis.exceptions.PersistenceException;
15 import org.apache.ibatis.executor.BatchResult;
16 import org.apache.ibatis.reflection.ExceptionUtil;
17 import org.apache.ibatis.session.Configuration;
18 import org.apache.ibatis.session.ExecutorType;
19 import org.apache.ibatis.session.ResultHandler;
20 import org.apache.ibatis.session.RowBounds;
21 import org.apache.ibatis.session.SqlSession;
22 import org.apache.ibatis.session.SqlSessionFactory;
23 import org.springframework.dao.support.PersistenceExceptionTranslator;
24 import org.springframework.util.Assert;
25
26 public class SqlSessionTemplate implements SqlSession {
27 private final SqlSessionFactory sqlSessionFactory;
28 private final ExecutorType executorType;
29 private final SqlSession sqlSessionProxy;
30 private final PersistenceExceptionTranslator exceptionTranslator;
31
32 public SqlSessionTemplate(SqlSessionFactory sqlSessionFactory) {
33 this(sqlSessionFactory, sqlSessionFactory.getConfiguration().getDefaultExecutorType());
34 }
35
36 public SqlSessionTemplate(SqlSessionFactory sqlSessionFactory, ExecutorType executorType) {
37 this(sqlSessionFactory, executorType, new MyBatisExceptionTranslator(sqlSessionFactory.getConfiguration().getEnvironment().getDataSource(), true));
38 }
39
40 public SqlSessionTemplate(SqlSessionFactory sqlSessionFactory, ExecutorType executorType, PersistenceExceptionTranslator exceptionTranslator) {
41 Assert.notNull(sqlSessionFactory, “Property ‘sqlSessionFactory’ is required”);
42 Assert.notNull(executorType, “Property ‘executorType’ is required”);
43 this.sqlSessionFactory = sqlSessionFactory;
44 this.executorType = executorType;
45 this.exceptionTranslator = exceptionTranslator;
46 this.sqlSessionProxy = (SqlSession)Proxy.newProxyInstance(SqlSessionFactory.class.getClassLoader(), new Class[]{SqlSession.class}, new SqlSessionTemplate.SqlSessionInterceptor());
47 }
48
49 public SqlSessionFactory getSqlSessionFactory() {
50 return this.sqlSessionFactory;
51 }
52
53 public ExecutorType getExecutorType() {
54 return this.executorType;
55 }
56
57 public PersistenceExceptionTranslator getPersistenceExceptionTranslator() {
58 return this.exceptionTranslator;
59 }
60
61 public T selectOne(String statement) {
62 return this.sqlSessionProxy.selectOne(statement);
63 }
64
65 public T selectOne(String statement, Object parameter) {
66 return this.sqlSessionProxy.selectOne(statement, parameter);
67 }
68
69 public <K, V> Map<K, V> selectMap(String statement, String mapKey) {
70 return this.sqlSessionProxy.selectMap(statement, mapKey);
71 }
72
73 public <K, V> Map<K, V> selectMap(String statement, Object parameter, String mapKey) {
74 return this.sqlSessionProxy.selectMap(statement, parameter, mapKey);
75 }
76
77 public <K, V> Map<K, V> selectMap(String statement, Object parameter, String mapKey, RowBounds rowBounds) {
78 return this.sqlSessionProxy.selectMap(statement, parameter, mapKey, rowBounds);
79 }
80
81 public List selectList(String statement) {
82 return this.sqlSessionProxy.selectList(statement);
83 }
84
85 public List selectList(String statement, Object parameter) {
86 return this.sqlSessionProxy.selectList(statement, parameter);
87 }
88
89 public List selectList(String statement, Object parameter, RowBounds rowBounds) {
90 return this.sqlSessionProxy.selectList(statement, parameter, rowBounds);
91 }
92
93 public void select(String statement, ResultHandler handler) {
94 this.sqlSessionProxy.select(statement, handler);
95 }
96
97 public void select(String statement, Object parameter, ResultHandler handler) {
98 this.sqlSessionProxy.select(statement, parameter, handler);
99 }
100
101 public void select(String statement, Object parameter, RowBounds rowBounds, ResultHandler handler) {
102 this.sqlSessionProxy.select(statement, parameter, rowBounds, handler);
103 }
104
105 public int insert(String statement) {
106 return this.sqlSessionProxy.insert(statement);
107 }
108
109 public int insert(String statement, Object parameter) {
110 return this.sqlSessionProxy.insert(statement, parameter);
111 }
112
113 public int update(String statement) {
114 return this.sqlSessionProxy.update(statement);
115 }
116
117 public int update(String statement, Object parameter) {
118 return this.sqlSessionProxy.update(statement, parameter);
119 }
120
121 public int delete(String statement) {
122 return this.sqlSessionProxy.delete(statement);
123 }
124
125 public int delete(String statement, Object parameter) {
126 return this.sqlSessionProxy.delete(statement, parameter);
127 }
128
129 public T getMapper(Class type) {
130 return this.getConfiguration().getMapper(type, this);
131 }
132
133 public void commit() {
134 throw new UnsupportedOperationException(“Manual commit is not allowed over a Spring managed SqlSession”);
135 }
136
137 public void commit(boolean force) {
138 throw new UnsupportedOperationException(“Manual commit is not allowed over a Spring managed SqlSession”);
139 }
140
141 public void rollback() {
142 throw new UnsupportedOperationException(“Manual rollback is not allowed over a Spring managed SqlSession”);
143 }
144
145 public void rollback(boolean force) {
146 throw new UnsupportedOperationException(“Manual rollback is not allowed over a Spring managed SqlSession”);
147 }
148
149 public void close() {
150 throw new UnsupportedOperationException(“Manual close is not allowed over a Spring managed SqlSession”);
151 }
152
153 public void clearCache() {
154 this.sqlSessionProxy.clearCache();
155 }
156
157 public Configuration getConfiguration() {
158 return this.sqlSessionFactory.getConfiguration();
159 }
160
161 public Connection getConnection() {
162 return this.sqlSessionProxy.getConnection();
163 }
164
165 public List flushStatements() {
166 return this.sqlSessionProxy.flushStatements();
167 }
168
169 private class SqlSessionInterceptor implements InvocationHandler {
170 private SqlSessionInterceptor() {
171 }
172
173 public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
174 SqlSession sqlSession = SqlSessionUtils.getSqlSession(SqlSessionTemplate.this.sqlSessionFactory, SqlSessionTemplate.this.executorType, SqlSessionTemplate.this.exceptionTranslator);
175
176 Object unwrapped;
177 try {
178 Object result = method.invoke(sqlSession, args);
179 if (!SqlSessionUtils.isSqlSessionTransactional(sqlSession, SqlSessionTemplate.this.sqlSessionFactory)) {
180 sqlSession.commit(true);
181 }
182
183 unwrapped = result;
184 } catch (Throwable var11) {
185 unwrapped = ExceptionUtil.unwrapThrowable(var11);
186 if (SqlSessionTemplate.this.exceptionTranslator != null && unwrapped instanceof PersistenceException) {
187 SqlSessionUtils.closeSqlSession(sqlSession, SqlSessionTemplate.this.sqlSessionFactory);
188 sqlSession = null;
189 Throwable translated = SqlSessionTemplate.this.exceptionTranslator.translateExceptionIfPossible((PersistenceException)unwrapped);
190 if (translated != null) {
191 unwrapped = translated;
192 }
193 }
194
195 throw (Throwable)unwrapped;
196 } finally {
197 if (sqlSession != null) {
198 SqlSessionUtils.closeSqlSession(sqlSession, SqlSessionTemplate.this.sqlSessionFactory);
199 }
200
201 }
202
203 return unwrapped;
204 }
205 }
206 }

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

spring 整合 mybatis 中数据源的几种配置总结 的相关文章

  • 深聊测开领域之:一文搞懂什么是敏捷测试,如何做敏捷测试,建议先收藏再学习。

    敏捷测试 1 引言 2 解析敏捷测试 2 1 含义 2 2 特点 2 3 为什么要进行敏捷测试 2 4 敏捷测试与传统测试对比 2 5 如何迁移敏捷测试 2 6 敏捷测试成功因素 3 总结 1 引言 小屌丝 鱼哥 在忙呢 小鱼 昂 不忙 再
  • python环境配置什么意思_Python 环境配置

    Python 环境配置 在你开始学习 Python 之前最重要的是 对 你要安装 Python 环境 许多初学者会纠结应该选择 2 x 版本还是 3 x 版本的问题 在我看来 世界变化的速度在变得更快 语言的更新速度速度亦然 没有什么理由让
  • RocketMQ系列之入门

    前言 之前我们把RMQ的多Master集群搭建起来了 我们今天就来看看如何向这个集群生产消息以及消费消息 集群搭建回顾 回顾上节的内容 我总结下以下几步 第一 最新版RMQ4 2 0要求最低JDK8版本 第二 修改虚拟机的host 配置na
  • Nginx高可用主备模式

    我这里用的是VMware上的两台虚拟机 那个ip地址 就按照自己的配就行了哈 跟我一样也行的 也可以直接这么设置 我这里有两台机子 ip分别都是设置的静态ip 两台机子上分别都装上nginx和keepalived 这是安装keepalive
  • STM32 CAN通讯实验程序

    目录 STM32 CAN通讯实验 CAN硬件原理图 CAN外设原理图 TJA1050T硬件描述 实验线路图 回环实验 CAN头文件配置 CAN GPIO Config初始化 CAN初始化结构体 CAN筛选器结构体 接收中断优先级配置 接收中
  • [转]:如何让PowerDesigner支持自动生成含SQL Server 2000的表和列注释

    如何让PowerDesigner支持自动生成含SQL Server 2000的表和列注释的角本 PowerDesigner是Sybase公司著名的产品 我从16 bit的windows开始 就接触并使用这个工具 应该说是有很深的感情 Pow
  • 从零开始学习Redis(三)代码使用Redis

    1 安装完了之后就可以使用了 我是用的是SpringBoot整合Redis 咱们整个最简单的 新建一个maven项目 添加依赖
  • Python文本进度条-time库

    TextProBarV3 py import time scale 50 表示整数除法 返回不大于结果的一个最大的整数 print 执行开始 center scale 2 perf counter 返回一个CPU级别的精确时间计数值 单位为
  • Windows10安装VMware Workstation 15 Player遇到问题

    出现的问题 如下图 解决方法 以我电脑为例子 我的是联想的 1 在开机的时候 按F2进入BIOS界面 这个各品牌的电脑不一样 可能操作上有区别 2 选择configuration 再选择intel virtual technology 本来
  • Openssl base64命令

    一 简介 对文件件进行base64的编码与解码 二 语法 openssl base64 in filename out filename 三 实例 1 二进制文件与base64编码互转 openssl base64 in pubkey bi
  • python列表中元素相加_将所有嵌套列表中的元素相加

    首先 为Python程序员展示了一个通用的反模式 不要循环索引 循环对象本身 E g组 for item in b do something item 而不是 pr2 它更清晰 更简单 更快 在 也就是说 你遇到的主要问题是其中一项不是列表
  • 解耦利器:带你快速了解控制反转以及依赖注入

    前言 在我们的后端工程中 面临着一个很严峻的问题 代码的体量太大了 那么我们如果不能很好的处理各个方法之间的关系 就会对后期的代码维护和更新造成很大的问题 例如可能只是一次对方法的简单更改 却要改动一系列调用这个方法的相关代码 而我们今天要
  • c++系列八 —— STL编程之容器类

    往期地址 c 系列一 c 的封装 c 系列二 c 的继承 c 系列三 继承和多态特性 c 系列四 运算符重载 c 系列五 静态成员和静态类 c 系列六 友元函数和友元类 c 系列七 STL编程之模板template 本期主题 STL编程之容
  • web前端网页制作思路(只是思路)

    分享一下web前端网页制作的思路 首先 当你拿到一个项目关于网页设计的 比如类似于写一个类似于百度图片的搜索引擎 类似于这样 你会首先想到的是什么呢 先是这个背景呢 上面的文字呢还是说中间的文字 暂时我们只是讲一讲思路 谈一谈如何去做 好的
  • iOS编程基础-Swift(一)-Swift架构纵览

    Swift入门指南 iOS9 Programming Fundamentals With Swift 语言 第一章 从概念与实践上介绍Swift程序的结构 第二章 介绍Swift 函数 第三章 介绍Swift变量 第四章 介绍Swift对象
  • 计算机 国际顶尖级会议排名,计算机学科国际会议排名

    序号 会议名称 会议介绍 代表领域 1 ACM SIGCOMM ACM Conf on Communication Architectures Protocols Apps ACM的旗舰会议之一 也是网络领域顶级学术会议 内容侧重于有线网络
  • 电脑提示d3dcompiler_47.dll缺失怎么修复?

    我们再打开游戏或者软件的时候 电脑提示d3dcompiler 47 dll缺失无法打开运行需要怎么修复呢 d3dcompiler 47 dll是电脑系统非常重要的文件 是游戏跟软件运行必要的底层程序 小编今天就把修复教程分享给大家 修复教程
  • Seata 多路服务调用时事务不回滚解决办法

    最近使用了Seata作为分布式事务管理工具 在一般情况如 A服务调用B服务且A服务调用C服务 即A B A C这种服务调用链路 当其中任意一个服务报错 事务是可以回滚的 然而 稍微复杂一点的情况我发现seata事务居然不会回滚了 即A B
  • 关于知识图谱

    知识图谱 Knowledge Graph 什么是知识图谱 知识图谱这一概念最早由Google公司提出 其最初是为了提高搜索引擎的能力而设计的 知识图谱的定义有很多种 但是最为广泛接受的一种定义是 知识图谱是一种语义网络 什么是语义网络呢 网
  • Caesar密码的生成与破解

    背景 在密码学中 恺撒密码 英语 Caesarcipher 或称恺撒加密 恺撒变换 变换加密 是一种最简单且最广为人知的加密技术 它是一种替换加密的技术 明文中的所有字母都在字母表上向后 或向前 按照一个固定数目进行偏移后被替换成密文 例如

随机推荐

  • 和quicklook相似的软件_细数软件推荐爆文中出现比例较高的10款软件,看看谁出现最多...

    前言 软件推荐文一直是大妈爆文备选题材之一 作为一个比较喜欢用数据说话的鸽主 在电脑椅方面统计了不少数据 帮助不少人选择和使用电脑椅 所以这次也不例外 不过这回把手伸向了软件 软件推荐文中 很多人有长期使用的经验 所以对某些软件来说 就因为
  • 【C语言】输入一个十进制正整数,将它对应的二进制数的各位逆序,形成新的十进制数输出。题目分析及拓展应用。

    目录 一 题目及答案 二 对该题目的分析及详解 三 对该题的举一反三 1 将十进制数对应的n进制数各位逆序 形成新的十进制输出 2 将十进制数转换成相应的n进制数输出 一 题目及答案 如图 题目及答案如下 该程序完整代码如下 需要可自由复制
  • Eclipse使用入门

    工欲善其事 必先利其器 假若能熟练Eclipse 对于我们编写java程序会起到事半功倍的效果 大大提高我们工作效率 因此本篇博文 笔者只是针对刚刚入门java的新手 以便他们能尽快掌握Eclipse的使用 一 常用快捷键 这是使用工具的第
  • Quartus-II的安装教程

    Quartus II的安装教程 文章目录 Quartus II的安装教程 一 Quartus II的下载 二 Quartus II的安装 1 解压压缩包 2 进行安装 三 注册Quartus II 一 Quartus II的下载 百度网盘下
  • python pandas ExcelWriter FutureWarning: save is not part of the public API

    升级了Python 到3 10 然后pandas写的ExcelWriter也跟着升级了 以下是版本 pandas 1 5 0 xlwt 1 3 0 然后是执行原来的导数据到Excel的代码报错警告 FutureWarning save is
  • Mybatis的分页插件

    一 添加依赖
  • JAVA多线程与并发学习总结

    1 计算机系统 使用高速缓存来作为内存与处理器之间的缓冲 将运算需要用到的数据复制到缓存中 让计算能快速进行 当运算结束后再从缓存同步回内存之中 这样处理器就无需等待缓慢的内存读写了 缓存一致性 多处理器系统中 因为共享同一主内存 当多个处
  • MAC升级10.15不能使用[远程桌面连接]--解决方案

    MACBook升级10 15之后发现远程桌面无法打开 提示如下 各种找资料 主要是威锋网 均无法解决 只能换软件了 替代软件 Microsoft Remote Desktop 8 0 7版本 比较好用 软件下载地址 链接 https pan
  • java的各类型数据在内存中分配情况详解

    有这样一种说法 如今争锋于IT战场的两大势力 MS一族偏重于底层实现 Java一族偏重于系统架构 说法根据无从考证 但从两大势力各自的社区力量和图书市场已有佳作不难看出 此说法不虚 但掌握Java的底层实现对Java程序员来说是至关重要的
  • IC,ID卡二进制数据解析

    IC卡数据 一般10位 第一位 20 第四位 数据长度 第9位 校验位 最后一位03 如 20 00 00 04 03 CA C3 58 A9 03 ID卡 第一位02 第二位 数据长度 倒数第二位校验位 最后一位03 02 05 1D 0
  • Spyder设置代码自动补全

    1 spyder 代码自动补齐设置方式在tools gt preferences gt IPython console gt advanced Settings 下面 把User the greedy completer 勾选上 再把Aut
  • Linux笔记:增量备份程序rsync快速入门

    文章目录 目的 快速入门 常用选项 总结 目的 rsync是一款开源的文件增量备份程序 通常用于linux下文件的增量备份 这个程序可以将一个目录的文件备份到另一个目录中 并且在每次备份时还可以对文件进行比较 只复制更新有过改动的文件 rs
  • 《代码之丑》——专栏笔记

    一 如何精确命名 错误1 命名过于宽泛 命名过于宽泛 不能精准描述 这是很多代码在命名上存在的严重问题 也是代码难以理解的根源所在 data info flag process handle build maintain manage mo
  • 数字图像处理之校园交通标志检测与识别

    文章目录 背景综述 设计目的 实现过程 第一步为了更好地进行信息的交互 需要先设计基于Matlab的GUI界面设计 第二步其次我们需要读入含有交通标志的图像 第三步接下来是对原始图像进行高斯滤波 第四步为了进行交通标志的提取 第五步对初步定
  • 一、安装虚拟机(CentOS)

    1二 修改主机名 当前虚拟机的主机名 1 查看当前的主机名 1 hostname 第一种方法 vi etc hostname 编辑完需要重启 重启 reboot h now 第二种方法 hostnamectl set hostname lt
  • 小程序AR踩坑记录

    使用微信自带的 VisionKit API提供 AR 能力 官方手册地址 VisionKit 基础 虽然官方提供了 demo 代码 但是埋藏的暗坑还是不少 特此总结一下 DEMO案例 待添加 逻辑流程 大致流程如下 用户访问 AR 页面 程
  • Vue 将数组的字段取出组成key:value形式的对象+key:value 形式的对象组成数组

    1 将数组的字段取出组成key value形式的对象 let list key php value 1 key asp value 2 key aspx value 3 key jsp value 4 let header list for
  • jdk11生成jre

    1 在jdk11的解压目录中没有jre 2 执行 cmd D java jdk 11 0 17 3 执行 bin jlink exe module path jmods add modules java desktop output jre
  • Apollo代码学习(一)—控制模块概述

    Apollo代码学习 控制模块概述 补充 2018 11 08更新 2018 11 15更新 2018 11 20更新 前言 控制 纵向控制 标定表的生成 横向控制 控制信号 仿真 仿真平台及工具 Apollo 阿波罗 是一个开放的 完整的
  • spring 整合 mybatis 中数据源的几种配置总结

    spring 整合 mybatis 中数据源的几种配置方式 因为spring 整合mybatis的过程中 有好几种整合方式 尤其是数据源那块 经常看到不一样的配置方式 总感觉有点乱 所以今天有空总结下 一 采用org mybatis spr