百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 热门文章 > 正文

Java之MyBatis源码分析 insert、update、delete处理流程(上篇)

bigegpt 2024-08-03 11:48 60 浏览

打开一个会话Session

前文分析了MyBatis将配置文件转换为Java对象的流程,本文开始分析一下insert方法、update方法、delete方法处理的流程,至于为什么这三个方法要放在一起说,是因为:

  1. 从语义的角度,insert、update、delete都是属于对数据库的行进行更新操作
  2. 从实现的角度,我们熟悉的PreparedStatement里面提供了两种execute方法,一种是executeUpdate(),一种是executeQuery(),前者对应的是insert、update与delete,后者对应的是select,因此对于MyBatis来说只有update与select

示例代码为这段:

1 public long insertMail(Mail mail) {
 2 SqlSession ss = ssf.openSession();
 3 try {
 4 int rows = ss.insert(NAME_SPACE + "insertMail", mail);
 5 ss.commit();
 6 if (rows > 0) {
 7 return mail.getId();
 8 }
 9 return 0;
10 } catch (Exception e) {
11 ss.rollback();
12 return 0;
13 } finally {
14 ss.close();
15 }
16 }

首先关注的是第2行的代码,ssf是SqlSessionFactory,其类型是DefaultSqlSessionFactory,上文最后已经分析过了,这里通过DefaultSqlSessionFactory来打开一个Session,通过Session去进行CRUD操作。

看一下openSession()方法的实现:

1 public SqlSession openSession() {
2 return openSessionFromDataSource(configuration.getDefaultExecutorType(), null, false);
3 }

顾名思义,从DataSource中获取Session,第一个参数的值是ExecutorType.SIMPLE,继续跟代码:

 1 private SqlSession openSessionFromDataSource(ExecutorType execType, TransactionIsolationLevel level, boolean autoCommit) {
 2 Transaction tx = null;
 3 try {
 4 final Environment environment = configuration.getEnvironment();
 5 final TransactionFactory transactionFactory = getTransactionFactoryFromEnvironment(environment);
 6 tx = transactionFactory.newTransaction(environment.getDataSource(), level, autoCommit);
 7 final Executor executor = configuration.newExecutor(tx, execType);
 8 return new DefaultSqlSession(configuration, executor, autoCommit);
 9 } catch (Exception e) {
10 closeTransaction(tx); // may have fetched a connection so lets call close()
11 throw ExceptionFactory.wrapException("Error opening session. Cause: " + e, e);
12 } finally {
13 ErrorContext.instance().reset();
14 }
15 }

第4行的代码,获取配置的环境信息Environment。

第5行的代码,从Environment中获取事物工厂TransactionFactory,由于<environment>中配置的是"JDBC",因此其真实类型是JdbcTransactionFactory,上文有说过。

第6行的代码,根据Environment中的DataSource(其实际类型是PooledDataSource)、TransactionIsolationLevel、autoCommit三个参数从TransactionFactory中获取一个事物,注意第三个参数autoCommit,它是openSession()方法中传过来的,其值为false,即MyBatis默认事物是不自动提交的

第7行的代码,实现跟一下:

 1 public Executor newExecutor(Transaction transaction, ExecutorType executorType) {
 2 executorType = executorType == null ? defaultExecutorType : executorType;
 3 executorType = executorType == null ? ExecutorType.SIMPLE : executorType;
 4 Executor executor;
 5 if (ExecutorType.BATCH == executorType) {
 6 executor = new BatchExecutor(this, transaction);
 7 } else if (ExecutorType.REUSE == executorType) {
 8 executor = new ReuseExecutor(this, transaction);
 9 } else {
10 executor = new SimpleExecutor(this, transaction);
11 }
12 if (cacheEnabled) {
13 executor = new CachingExecutor(executor);
14 }
15 executor = (Executor) interceptorChain.pluginAll(executor);
16 return executor;
17 }

这里总结一下:

  • 根据ExecutorType获取一个执行器,这里是第10行的SimpleExecutor
  • 如果满足第12行的判断开启缓存功能,则执行第13行的代码。第13行的代码使用到了装饰器模式,传入Executor,给SimpleExecutor装饰上了缓存功能
  • 第15行的代码用于设置插件

这样就获取了一个Executor。最后将Executor、Configuration、autoCommit三个变量作为参数,实例化一个SqlSession出来,其实际类型为DefaultSqlSession。

insert方法执行流程

在看了openSession()方法知道最终获得了一个DefaultSqlSession之后,看一下DefaultSqlSession的insert方法是如何实现的:

 1 public int insert(String statement, Object parameter) {
 2 return update(statement, parameter);
 3 }

看到虽然调用的是insert方法,但是最终统一都会去执行update方法,delete方法也是如此,这个开头已经说过了,这里证明了这一点。

接着继续看第2行的方法实现:

 1 public int update(String statement, Object parameter) {
 2 try {
 3 dirty = true;
 4 MappedStatement ms = configuration.getMappedStatement(statement);
 5 return executor.update(ms, wrapCollection(parameter));
 6 } catch (Exception e) {
 7 throw ExceptionFactory.wrapException("Error updating database. Cause: " + e, e);
 8 } finally {
 9 ErrorContext.instance().reset();
10 }
11 }

第4行的代码根据statement从Configuration中获取MappedStatement,MappedStatement上文已经分析过了,存储在Configuration的mappedStatements字段中。

第5行的代码分为两部分,首先wrapCollection,顾名思义包装集合类,源码为:

 1 private Object wrapCollection(final Object object) {
 2 if (object instanceof Collection) {
 3 StrictMap<Object> map = new StrictMap<Object>();
 4 map.put("collection", object);
 5 if (object instanceof List) {
 6 map.put("list", object);
 7 }
 8 return map;
 9 } else if (object != null && object.getClass().isArray()) {
10 StrictMap<Object> map = new StrictMap<Object>();
11 map.put("array", object);
12 return map;
13 }
14 return object;
15 }

这里做了三层处理:

  • 如果参数是Collection(即集合)类型,放一个key为"collection"、value为参数的键值对
  • 如果参数是List类型,放一个key为"list"、value为参数的键值对
  • 如果参数是数组类型,放一个key为"array"、value为参数的键值对

将集合进行包装之后,就可以执行Executor的update方法了,Executor上面说了,是使用装饰器模式将SimpleExecutor加上了缓存功能的CacheExecutor,它的update方法实现为:

1 public int update(MappedStatement ms, Object parameterObject) throws SQLException {
2 flushCacheIfRequired(ms);
3 return delegate.update(ms, parameterObject);
4 }

第2行的代码是判断是否要求清缓存的,这里首先我们的示例配置文件mail.xml中没有配置<cache>,其次<insert>、<delete>、<update>、<select>中没有配置flushCache="true"属性,因此这一句代码不会执行任何操作。

第3行的代码delegate就是SimpleExecutor本身,因为是装饰器模式,因此会持有接口的引用,deletegate其类型就是Executor。继续跟代码,看一下update方法:

1 public int update(MappedStatement ms, Object parameter) throws SQLException {
2 ErrorContext.instance().resource(ms.getResource()).activity("executing an update").object(ms.getId());
3 if (closed) {
4 throw new ExecutorException("Executor was closed.");
5 }
6 clearLocalCache();
7 return doUpdate(ms, parameter);
8 }

前面的没什么好看的,继续跟第7行的代码:

 1 public int doUpdate(MappedStatement ms, Object parameter) throws SQLException {
 2 Statement stmt = null;
 3 try {
 4 Configuration configuration = ms.getConfiguration();
 5 StatementHandler handler = configuration.newStatementHandler(this, ms, parameter, RowBounds.DEFAULT, null, null);
 6 stmt = prepareStatement(handler, ms.getStatementLog());
 7 return handler.update(stmt);
 8 } finally {
 9 closeStatement(stmt);
10 }
11 }

第4行的代码获取MappedStatement中的Configuration对象。

第5行的代码获取Statement处理器StatementHandler接口实现类,Statement是Java原生的为JDBC设计的声明,StatementHandler接口实现类的真实类型为RoutingStatementHandler。

第6行和第7行的代码后文逐步分析,因为里面一点一点封装了我们平时写JDBC时的一些基本步骤,比如获取Connection,构建PreparedStatement、对execute后的结果进行处理等,先看一下prepareStatement的源码:

1 private Statement prepareStatement(StatementHandler handler, Log statementLog) throws SQLException {
2 Statement stmt;
3 Connection connection = getConnection(statementLog);
4 stmt = handler.prepare(connection, transaction.getTimeout());
5 handler.parameterize(stmt);
6 return stmt;
7 }

后面逐步分析。

获取Connection

第一步,看下获取Connection的步骤。看一下上面getConnection方法如何实现:

1 protected Connection getConnection(Log statementLog) throws SQLException {
2 Connection connection = transaction.getConnection();
3 if (statementLog.isDebugEnabled()) {
4 return ConnectionLogger.newInstance(connection, statementLog, queryStack);
5 } else {
6 return connection;
7 }
8 }

Connection从Transaction中获取,配置的是JDBC,这里代码进入JdbcTransaction的getConnection():

1 protected Connection getConnection(Log statementLog) throws SQLException {
2 Connection connection = transaction.getConnection();
3 if (statementLog.isDebugEnabled()) {
4 return ConnectionLogger.newInstance(connection, statementLog, queryStack);
5 } else {
6 return connection;
7 }
8 }

先看一下第3行~第7行的代码,判断的意思是是否开启Statement的表达式,如果开启,那么第4行会给生成的Connection加上一个代理,代理的内容是在调用prepareStatement、prepareCall等方法前或者方法后打印日志,具体可见ConnectionLogger、PreparedStatementLogger、ResultSetLogger与StatementLogger的invoke方法。

接着继续跟第2行的代码:

1 public Connection getConnection() throws SQLException {
2 if (connection == null) {
3 openConnection();
4 }
5 return connection;
6 }

跟一下第3行的代码:

 1 protected void openConnection() throws SQLException {
 2 if (log.isDebugEnabled()) {
 3 log.debug("Opening JDBC Connection");
 4 }
 5 connection = dataSource.getConnection();
 6 if (level != null) {
 7 connection.setTransactionIsolation(level.getLevel());
 8 }
 9 setDesiredAutoCommit(autoCommmit);
10 }

第6行~第8行的代码用于设置事物隔离级别,第9行的代码用于设置是否自动提交事物。下面跟一下第5行的代码getConnection()方法:

1 public Connection getConnection() throws SQLException {
2 return popConnection(dataSource.getUsername(), dataSource.getPassword()).getProxyConnection();
3 }

这里简单提一下,在方法名中如果看到了"pop"、"push"字样,一定要把该方法使用的数据结构和栈联想起来,栈(stack)是一个后进先出的数据结构,"pop"、"push"是栈特有的操作,前者将栈顶的数据推送出栈让调用者获取到,后者将数据压入栈顶

后面的getProxyConnection()方法就是将获取到的Connection返回而已,没什么特殊的操作,这里跟一下popConnection方法实现,它位于PooledDataSource类中,这是由<dataSource>标签中的type属性决定的:

 1 private PooledConnection popConnection(String username, String password) throws SQLException {
 2 boolean countedWait = false;
 3 PooledConnection conn = null;
 4 long t = System.currentTimeMillis();
 5 int localBadConnectionCount = 0;
 6 
 7 while (conn == null) {
 8 synchronized (state) {
 9 if (!state.idleConnections.isEmpty()) {
 10 // Pool has available connection
 11 conn = state.idleConnections.remove(0);
 12 if (log.isDebugEnabled()) {
 13 log.debug("Checked out connection " + conn.getRealHashCode() + " from pool.");
 14 }
 15 } else {
 16 // Pool does not have available connection
 17 if (state.activeConnections.size() < poolMaximumActiveConnections) {
 18 // Can create new connection
 19 conn = new PooledConnection(dataSource.getConnection(), this);
 20 if (log.isDebugEnabled()) {
 21 log.debug("Created connection " + conn.getRealHashCode() + ".");
 22 }
 23 } else {
 24 // Cannot create new connection
 25 PooledConnection oldestActiveConnection = state.activeConnections.get(0);
 26 long longestCheckoutTime = oldestActiveConnection.getCheckoutTime();
 27 if (longestCheckoutTime > poolMaximumCheckoutTime) {
 28 // Can claim overdue connection
 29 state.claimedOverdueConnectionCount++;
 30 state.accumulatedCheckoutTimeOfOverdueConnections += longestCheckoutTime;
 31 state.accumulatedCheckoutTime += longestCheckoutTime;
 32 state.activeConnections.remove(oldestActiveConnection);
 33 if (!oldestActiveConnection.getRealConnection().getAutoCommit()) {
 34 try {
 35 oldestActiveConnection.getRealConnection().rollback();
 36 } catch (SQLException e) {
 37 log.debug("Bad connection. Could not roll back");
 38 } 
 39 }
 40 conn = new PooledConnection(oldestActiveConnection.getRealConnection(), this);
 41 oldestActiveConnection.invalidate();
 42 if (log.isDebugEnabled()) {
 43 log.debug("Claimed overdue connection " + conn.getRealHashCode() + ".");
 44 }
 45 } else {
 46 // Must wait
 47 try {
 48 if (!countedWait) {
 49 state.hadToWaitCount++;
 50 countedWait = true;
 51 }
 52 if (log.isDebugEnabled()) {
 53 log.debug("Waiting as long as " + poolTimeToWait + " milliseconds for connection.");
 54 }
 55 long wt = System.currentTimeMillis();
 56 state.wait(poolTimeToWait);
 57 state.accumulatedWaitTime += System.currentTimeMillis() - wt;
 58 } catch (InterruptedException e) {
 59 break;
 60 }
 61 }
 62 }
 63 }
 64 if (conn != null) {
 65 if (conn.isValid()) {
 66 if (!conn.getRealConnection().getAutoCommit()) {
 67 conn.getRealConnection().rollback();
 68 }
 69 conn.setConnectionTypeCode(assembleConnectionTypeCode(dataSource.getUrl(), username, password));
 70 conn.setCheckoutTimestamp(System.currentTimeMillis());
 71 conn.setLastUsedTimestamp(System.currentTimeMillis());
 72 state.activeConnections.add(conn);
 73 state.requestCount++;
 74 state.accumulatedRequestTime += System.currentTimeMillis() - t;
 75 } else {
 76 if (log.isDebugEnabled()) {
 77 log.debug("A bad connection (" + conn.getRealHashCode() + ") was returned from the pool, getting another connection.");
 78 }
 79 state.badConnectionCount++;
 80 localBadConnectionCount++;
 81 conn = null;
 82 if (localBadConnectionCount > (poolMaximumIdleConnections + 3)) {
 83 if (log.isDebugEnabled()) {
 84 log.debug("PooledDataSource: Could not get a good connection to the database.");
 85 }
 86 throw new SQLException("PooledDataSource: Could not get a good connection to the database.");
 87 }
 88 }
 89 }
 90 }
 91 
 92 }
 93 
 94 if (conn == null) {
 95 if (log.isDebugEnabled()) {
 96 log.debug("PooledDataSource: Unknown severe error condition. The connection pool returned a null connection.");
 97 }
 98 throw new SQLException("PooledDataSource: Unknown severe error condition. The connection pool returned a null connection.");
 99 }
100 
101 return conn;
102 }

这段方法很长,分解一下。

首先是第9行~第15行的判断,假使空闲的Connection列表不是空的,Connection就是空闲Connection列表的第一个Connection,且移除空闲Connection列表的第一个Connection,这也符合PooledDataSource的定义,有一个Connection池,对Connection进行复用而不是每次都new出来,这就是典型的栈的操作。但是这里有一点我认为MyBatis写得不是很好,List的实际类型是ArrayList,每次的移除操作是remove(0),ArrayList处理remove效率并不高尤其还是remove(0)的操作,因此这里替换成LinkedList会更好一些。

接着先看第23行~第63行的判断,它的判断逻辑是假如当前在使用的Connection数量大于或等于最大可用的Connection数量,那么获取当前正在使用的Connection列表中的第一个Connection做一个判断:

  1. 如果当前Connection执行时间已经超过了指定的Connection最大超时时间,那么原Connection如果不是自动Commit的,数据回滚,新建一个Connection,原Connection失效
  2. 如果当前Connection执行时间没有超过指定的Connection最大超时时间,那么使用wait方法等待

最后回到第17行~第23行的判断,即当前在使用的Connection数量小于最大可用的Connection数量,那么此时直接new一个PooledConnection出来,看一下PooledDataSource的getConnection()方法实现:

1 public Connection getConnection() throws SQLException {
2 return doGetConnection(username, password);
3 }

继续跟代码doGetConnection方法:

 1 private Connection doGetConnection(String username, String password) throws SQLException {
 2 Properties props = new Properties();
 3 if (driverProperties != null) {
 4 props.putAll(driverProperties);
 5 }
 6 if (username != null) {
 7 props.setProperty("user", username);
 8 }
 9 if (password != null) {
10 props.setProperty("password", password);
11 }
12 return doGetConnection(props);
13 }

这里就是先设置一下配置的属性,继续跟第12行的方法实现:

1 private Connection doGetConnection(Properties properties) throws SQLException {
2 initializeDriver();
3 Connection connection = DriverManager.getConnection(url, properties);
4 configureConnection(connection);
5 return connection;
6 }

到了这里就是我们比较熟悉的代码了。

第2行的代码意思是MyBatis维护了一个Driver池registeredDrivers,如果我们的Driver不在Driver池里面,那么会尝试使用Class.forName方法初始化一下,成功的话加入Driver池中。

第3行的代码不说了,使用DriverManager的getConnection方法获取Connection,第4行的代码配置一下Connection,主要就是设置一下自动提交属性与事物隔离级别。

最后将生成的Connection返回出去,完成生成Connection的流程。

为Connection生成代理

上面解析了生成Connection的流程,代码到这里还没完还有一步,看一下PooledConnection的构造方法:

1 public PooledConnection(Connection connection, PooledDataSource dataSource) {
2 this.hashCode = connection.hashCode();
3 this.realConnection = connection;
4 this.dataSource = dataSource;
5 this.createdTimestamp = System.currentTimeMillis();
6 this.lastUsedTimestamp = System.currentTimeMillis();
7 this.valid = true;
8 this.proxyConnection = (Connection) Proxy.newProxyInstance(Connection.class.getClassLoader(), IFACES, this);
9 }

这里第8行的代码会为生成的Connection创建一个代理,PooledConnection本身就实现了InvocationHandler接口,看一下代理内容是什么,invoke方法的实现:

 1 public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
 2 String methodName = method.getName();
 3 if (CLOSE.hashCode() == methodName.hashCode() && CLOSE.equals(methodName)) {
 4 dataSource.pushConnection(this);
 5 return null;
 6 } else {
 7 try {
 8 if (!Object.class.equals(method.getDeclaringClass())) {
 9 // issue #579 toString() should never fail
10 // throw an SQLException instead of a Runtime
11 checkConnection();
12 }
13 return method.invoke(realConnection, args);
14 } catch (Throwable t) {
15 throw ExceptionUtil.unwrapThrowable(t);
16 }
17 }
18 }

这一步操作主要是为了处理close方法的,看一下pushConnection方法的实现:

 1 protected void pushConnection(PooledConnection conn) throws SQLException {
 2 
 3 synchronized (state) {
 4 state.activeConnections.remove(conn);
 5 if (conn.isValid()) {
 6 if (state.idleConnections.size() < poolMaximumIdleConnections && conn.getConnectionTypeCode() == expectedConnectionTypeCode) {
 7 state.accumulatedCheckoutTime += conn.getCheckoutTime();
 8 if (!conn.getRealConnection().getAutoCommit()) {
 9 conn.getRealConnection().rollback();
10 }
11 PooledConnection newConn = new PooledConnection(conn.getRealConnection(), this);
12 state.idleConnections.add(newConn);
13 newConn.setCreatedTimestamp(conn.getCreatedTimestamp());
14 newConn.setLastUsedTimestamp(conn.getLastUsedTimestamp());
15 conn.invalidate();
16 if (log.isDebugEnabled()) {
17 log.debug("Returned connection " + newConn.getRealHashCode() + " to pool.");
18 }
19 state.notifyAll();
20 } else {
21 state.accumulatedCheckoutTime += conn.getCheckoutTime();
22 if (!conn.getRealConnection().getAutoCommit()) {
23 conn.getRealConnection().rollback();
24 }
25 conn.getRealConnection().close();
26 if (log.isDebugEnabled()) {
27 log.debug("Closed connection " + conn.getRealHashCode() + ".");
28 }
29 conn.invalidate();
30 }
31 } else {
32 if (log.isDebugEnabled()) {
33 log.debug("A bad connection (" + conn.getRealHashCode() + ") attempted to return to the pool, discarding connection.");
34 }
35 state.badConnectionCount++;
36 }
37 }
38 }

代码的逻辑简单来说就是当调用close方法的时候,如果当前空闲Connection列表中的Connection数量小于指定空闲Connection列表中的数量(第二个判断connectionTypeCode的值为275950209,不知道是干什么的),那么会为原Connection生成一个PooledConnection并加入空闲Connection列表中。

如果不满足上面的条件,那么就直接调用Connection的close()方法并且让原Connection失效。

相关推荐

得物可观测平台架构升级:基于GreptimeDB的全新监控体系实践

一、摘要在前端可观测分析场景中,需要实时观测并处理多地、多环境的运行情况,以保障Web应用和移动端的可用性与性能。传统方案往往依赖代理Agent→消息队列→流计算引擎→OLAP存储...

warm-flow新春版:网关直连和流程图重构

本期主要解决了网关直连和流程图重构,可以自此之后可支持各种复杂的网关混合、多网关直连使用。-新增Ruoyi-Vue-Plus优秀开源集成案例更新日志[feat]导入、导出和保存等新增json格式支持...

扣子空间体验报告

在数字化时代,智能工具的应用正不断拓展到我们工作和生活的各个角落。从任务规划到项目执行,再到任务管理,作者深入探讨了这款工具在不同场景下的表现和潜力。通过具体的应用实例,文章展示了扣子空间如何帮助用户...

spider-flow:开源的可视化方式定义爬虫方案

spider-flow简介spider-flow是一个爬虫平台,以可视化推拽方式定义爬取流程,无需代码即可实现一个爬虫服务。spider-flow特性支持css选择器、正则提取支持JSON/XML格式...

solon-flow 你好世界!

solon-flow是一个基础级的流处理引擎(可用于业务规则、决策处理、计算编排、流程审批等......)。提供有“开放式”驱动定制支持,像jdbc有mysql或pgsql等驱动,可...

新一代开源爬虫平台:SpiderFlow

SpiderFlow:新一代爬虫平台,以图形化方式定义爬虫流程,不写代码即可完成爬虫。-精选真开源,释放新价值。概览Spider-Flow是一个开源的、面向所有用户的Web端爬虫构建平台,它使用Ja...

通过 SQL 训练机器学习模型的引擎

关注薪资待遇的同学应该知道,机器学习相关的岗位工资普遍偏高啊。同时随着各种通用机器学习框架的出现,机器学习的门槛也在逐渐降低,训练一个简单的机器学习模型变得不那么难。但是不得不承认对于一些数据相关的工...

鼠须管输入法rime for Mac

鼠须管输入法forMac是一款十分新颖的跨平台输入法软件,全名是中州韵输入法引擎,鼠须管输入法mac版不仅仅是一个输入法,而是一个输入法算法框架。Rime的基础架构十分精良,一套算法支持了拼音、...

Go语言 1.20 版本正式发布:新版详细介绍

Go1.20简介最新的Go版本1.20在Go1.19发布六个月后发布。它的大部分更改都在工具链、运行时和库的实现中。一如既往,该版本保持了Go1的兼容性承诺。我们期望几乎所...

iOS 10平台SpriteKit新特性之Tile Maps(上)

简介苹果公司在WWDC2016大会上向人们展示了一大批新的好东西。其中之一就是SpriteKitTileEditor。这款工具易于上手,而且看起来速度特别快。在本教程中,你将了解关于TileE...

程序员简历例句—范例Java、Python、C++模板

个人简介通用简介:有良好的代码风格,通过添加注释提高代码可读性,注重代码质量,研读过XXX,XXX等多个开源项目源码从而学习增强代码的健壮性与扩展性。具备良好的代码编程习惯及文档编写能力,参与多个高...

Telerik UI for iOS Q3 2015正式发布

近日,TelerikUIforiOS正式发布了Q32015。新版本新增对XCode7、Swift2.0和iOS9的支持,同时还新增了对数轴、不连续的日期时间轴等;改进TKDataPoin...

ios使用ijkplayer+nginx进行视频直播

上两节,我们讲到使用nginx和ngixn的rtmp模块搭建直播的服务器,接着我们讲解了在Android使用ijkplayer来作为我们的视频直播播放器,整个过程中,需要注意的就是ijlplayer编...

IOS技术分享|iOS快速生成开发文档(一)

前言对于开发人员而言,文档的作用不言而喻。文档不仅可以提高软件开发效率,还能便于以后的软件开发、使用和维护。本文主要讲述Objective-C快速生成开发文档工具appledoc。简介apple...

macOS下配置VS Code C++开发环境

本文介绍在苹果macOS操作系统下,配置VisualStudioCode的C/C++开发环境的过程,本环境使用Clang/LLVM编译器和调试器。一、前置条件本文默认前置条件是,您的开发设备已...