(1-10-2)MyBatis 进阶篇 - 教程

news/2025/9/22 19:27:56/文章来源:https://www.cnblogs.com/lxjshuju/p/19105894

目录

1. MyBatis 日志管理

1.1 日志概述

1.2 (logback)日志环境配置

01. pom.xml

02. 运行测试方法

03. 配置logback.xml文件

2. 动态SQL的使用

2.1 概述

2.2 goods.xml

2.3 testDynamicSQL()

2.4 实现效果

3. MyBatis 二级缓存

3.1 缓存范围 与 运行规则

3.2 测试一级缓存

3.3 sqlSession.commit() 强制清空 已有的缓存

3.4 开启二级缓存

(1)查询标签设置useCache="true"开启缓存:

(2)插入标签设置flushCache="true"清空缓存

4. 一对多 & 多对一  对象关联查询

4.1 oneToMany 对象关联查询

(1) 创建 GoodsDetail 实体类

(2)goods新增 List结果集

(3)编写 goods_detail.xml 的 selectGoodsDetailByGoodsId 查询标签

(4) mybatis-config.xml 中添加配置

(4) 编写 goods.xml 的 rmGoodsOneToMany结果集

(5)编写 selectOneTo(Many 查询标签

  (6)  编写 testOneToMany() 测试方法

(7)debug 效果

4.2 ManyToOne 对象关联查询

(1) 编写 goods_detail.xml 的结果集 rmGoodsDetailManyToOne

(2)编写多对一 查询selectManyToOne 标签

(3)编写测试类 testManyToOne()

(4)debug 效果

5. 分页查询插件PageHelper

5.0 base

(1) 分页查询的麻烦事

5.1 PageHelper

5.2 pageHelper 使用流程

(1) 引入依赖

(2)mybatis-config.xml 中增 Pagehelper 配置

(3)goods.xml 中添加分页查询标签

(4) 编写测试方法 testSelectPage()

(5) 封装实现

(6) 实现效果

6.Mybatis 配置 C3P0 连接池

6.1 引入 c3p0 依赖

6.2 创建C3P0 与 Mybatis 兼容使用的数据源工厂类

6.3 mybatis-config.xml 中配置C3P0 的相关连接信息

7. Mybatis 批处理 SQL

7.1 批量插入

(1)编写SQL标签

(2) 编写测试类

7.2 批量删除

(1) 编写SQL标签

(2)测试方法 testBatchDelete

8. MyBatis 注解开发

8.1 MyBatis 的常用注解

8.2 @Select

(1) 注释掉 mapper 标签

(2) 编写 GoodsDTO1 

(3) 编写 GoodsDAO 接口

(4)调整 mybatis-config.xml

(5)  测试 @Select 注解

8.3 @Insert

(1)编写接口

(2)编写测试类

(3)测试testSelectAll()


1. MyBatis 日志管理

1.1 日志概述

1.2 (logback)日志环境配置

01. pom.xml
ch.qos.logback
logback-classic
1.2.11
02. 运行测试方法
@Test
public void testSelectByTitle02() throws Exception{
SqlSession sqlSession = null;
try{
sqlSession = MyBatisUtils.openSession();
Map param = new HashMap();
param.put("title","'爱恩幼 孕妇护肤品润养颜睡眠面膜 100g'");
List list = sqlSession.selectList("goods.selectByTitleAndOrder", param);
for(Goods goods: list){
System.out.println(goods.getSubTitle() + ":" + goods.getDiscount());
}
}catch (Exception e){
throw e;
}finally{
MyBatisUtils.closeSession(sqlSession);
}
}

03. 配置logback.xml文件
[%thread] %d{HH:mm:ss:SSS} %-5level %logger{36} - %msg%n

2. 动态SQL的使用

2.1 概述

2.2 goods.xml

select * from t_goods
where
1=1
and categroy_id = #{categoryId}
and current_price < #{currentPrice}
-->
select * from t_goods
and category_id = #{categoryId}
and current_price < #{currentPrice}

2.3 testDynamicSQL()

@Test
public void testDynamicSQL() throws Exception{
SqlSession sqlSession = null;
try{
sqlSession = MyBatisUtils.openSession();
Map param = new HashMap();
param.put("categoryId", 44);
param.put("currentPrice", 500);
// 查询条件
List list = sqlSession.selectList("goods.dynamicSQL02", param);
for(Goods goods: list){
System.out.println(goods.getTitle() + ":" +goods.getGoodsId() +goods.getCategoryId() + ":" + goods.getCurrentPrice());
}
}catch (Exception e){
throw e;
}finally{
MyBatisUtils.closeSession(sqlSession);
}
}

2.4 实现效果

3. MyBatis 二级缓存

3.1 缓存范围 与 运行规则

3.2 测试一级缓存

@Test
public void testLvCache() throws Exception{
SqlSession sqlSession = null;
try{
sqlSession = MyBatisUtils.openSession();
Goods goods1 = sqlSession.selectOne("goods.selectById", 831);
Goods goods2 = sqlSession.selectOne("goods.selectById", 831);
System.out.println(goods1.hashCode() + "-"+ goods2.hashCode());
}catch (Exception e){
throw e;
}finally{
MyBatisUtils.closeSession(sqlSession);
}
}

在同一个会话中,下一次重复的查询会使用重复记录

3.3 sqlSession.commit() 强制清空 已有的缓存

3.4 开启二级缓存

@Test
public void testLvCache02() throws Exception{
SqlSession sqlSession = null;
try{
sqlSession = MyBatisUtils.openSession();
Goods goods1 = sqlSession.selectOne("goods.selectById", 831);
System.out.println(goods1.hashCode());
}catch (Exception e){
throw e;
}finally{
MyBatisUtils.closeSession(sqlSession);
}
try{
sqlSession = MyBatisUtils.openSession();
Goods goods3 = sqlSession.selectOne("goods.selectById", 831);
System.out.println(goods3.hashCode());
}catch (Exception e){
throw e;
}finally{
MyBatisUtils.closeSession(sqlSession);
}
}

(1)查询标签设置useCache="true"开启缓存:
select * from t_goods where goods_id = #{value};
(2)插入标签设置flushCache="true"清空缓存
insert into t_goods(title, sub_title, original_cost, current_price, discount, is_free_delivery, category_id)
values (#{title}, #{subTitle}, #{originalCost}, #{currentPrice}, #{discount}, #{isFreeDelivery}, #{categoryId})

4. 一对多 & 多对一  对象关联查询

4.1 oneToMany 对象关联查询

(1) 创建 GoodsDetail 实体类
package com.phdvb.mybatis.entity;
public class GoodsDetail {
private Integer gdId;
private Integer goodsId;
private String gdPicUrl;
private Integer gdOrder;
private Goods goods;
public Integer getGdId() {
return gdId;
}
public void setGdId(Integer gdId) {
this.gdId = gdId;
}
public Integer getGoodsId() {
return goodsId;
}
public void setGoodsId(Integer goodsId) {
this.goodsId = goodsId;
}
public String getGdPicUrl() {
return gdPicUrl;
}
public void setGdPicUrl(String gdPicUrl) {
this.gdPicUrl = gdPicUrl;
}
public Integer getGdOrder() {
return gdOrder;
}
public void setGdOrder(Integer gdOrder) {
this.gdOrder = gdOrder;
}
public Goods getGoods() {
return goods;
}
public void setGoods(Goods goods) {
this.goods = goods;
}
}
(2)goods新增 List<GoodsDetail> 结果集
public class Goods {
private Integer goodsId;            // 商品编号
private String title;               // 商品标题
private String subTitle;            // 子标题
private Float originalCost;         // 原始价格
private Float currentPrice;         // 当前价格
private Float discount;             // 折扣率
private Integer isFreeDelivery;     // 是否包邮(1-包邮, 0- 不包邮)
private Integer categoryId;         // 分类编号
private List goodsDetailList;
(3)编写 goods_detail.xml 的 selectGoodsDetailByGoodsId 查询标签
select * from t_goods_detail where goods_id = #{value}
(4) mybatis-config.xml 中添加配置
(4) 编写 goods.xml 的 rmGoodsOneToMany结果集
(5)编写 selectOneTo(Many 查询标签
select * from t_goods limit 0, 2
  (6)  编写 testOneToMany() 测试方法
/**
* 一对多对象 关联查询
*/
@Test
public void testOneToMany() throws Exception{
SqlSession sqlSession = null;
try{
sqlSession = MyBatisUtils.openSession();
List list = sqlSession.selectList("goods.selectOneToMany");
for(Goods goods: list){
System.out.println(goods.getTitle() + ":" + goods.getGoodsDetailList().size());
}
}catch(Exception e){
throw e;
}finally{
MyBatisUtils.closeSession(sqlSession);
}
}
(7)debug 效果

4.2 ManyToOne 对象关联查询

(1) 编写 goods_detail.xml 的结果集 rmGoodsDetailManyToOne
-->
(2)编写多对一 查询selectManyToOne 标签
select * from t_goods_detail limit 0, 20
(3)编写测试类 testManyToOne()
/**
* 多对一  关联查询
*/
@Test
public void testManyToOne() throws Exception{
SqlSession sqlSession = null;
try{
sqlSession = MyBatisUtils.openSession();
List list = sqlSession.selectList("goodsDetail.selectManyToOne");
for(GoodsDetail goodsDetail: list){
System.out.println(goodsDetail.getGdId() + ":" +goodsDetail.getGoodsId()+ ":" + goodsDetail.getGdPicUrl() + goodsDetail.getGoods().getSubTitle());
}
}catch(Exception e){
throw e;
}finally{
MyBatisUtils.closeSession(sqlSession);
}
}
(4)debug 效果

5. 分页查询插件PageHelper

5.0 base

(1) 分页查询的麻烦事

5.1 PageHelper

官方链接:

MyBatis 分页插件 PageHelper

如何使用分页插件doc:

如何使用分页插件

5.2 pageHelper 使用流程

(1) 引入依赖
com.github.pagehelper
pagehelper
5.1.8
com.github.jsqlparser
jsqlparser
2.0
(2)mybatis-config.xml 中增 Pagehelper 配置
(3)goods.xml 中添加分页查询标签
select * from t_goods where current_price < 800
(4) 编写测试方法 testSelectPage()
/**
* PageHelper 分页查询
*/
@Test
public void testSelectPage() throws Exception{
SqlSession sqlSession = null;
try{
sqlSession = MyBatisUtils.openSession();
/*
startPage 方法会自动将  下一次查询进行分页
*/
PageHelper.startPage(3,15);
Page page = (Page) sqlSession.selectList("goods.selectPage");
System.out.println("总页数:" + page.getPages());               //总页数:119
System.out.println("总记录数:" + page.getTotal());             //总记录数:1774
System.out.println("开始行号:" + page.getStartRow());          //开始行号:30
System.out.println("结束行号:" + page.getEndRow());            //结束行号:45
System.out.println("当前页码:" + page.getPageNum());           //当前页码:3
List list = page.getResult();
for (Goods good : list) {
System.out.println(good.getGoodsId() +"-"+ good.getSubTitle());
}
System.out.println();
}catch (Exception e){
throw e;
}finally{
MyBatisUtils.closeSession(sqlSession);
}
}
(5) 封装实现

(6) 实现效果

6.Mybatis 配置 C3P0 连接池

6.1 引入 c3p0 依赖

com.mchange
c3p0
0.9.5.4

6.2 创建C3P0 与 Mybatis 兼容使用的数据源工厂类

package com.phdvb.mybatis.datasource;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory;
/**
* C3P0 与 Mybatis 兼容使用的数据源工厂类
*/
public class C3P0DataSourceFactory extends UnpooledDataSourceFactory {
public C3P0DataSourceFactory() {
this.dataSource = new ComboPooledDataSource();
}
}

6.3 mybatis-config.xml 中配置C3P0 的相关连接信息

-->
-->
-->
-->
-->
-->

7. Mybatis 批处理 SQL

Q1:

batchInsert 无法获取新增数据的 Id

Q2:

批量生成的SQL太长,可能会被服务器拒绝

7.1 批量插入

(1)编写SQL标签
insert into t_goods(title, sub_title, original_cost, current_price, discount, is_free_delivery, category_id)
values
(
#{item.title},
#{item.subTitle},
#{item.originalCost},
#{item.currentPrice},
#{item.discount},
#{item.isFreeDelivery},
#{item.categoryId},
)
(2) 编写测试类
@Test
public void testBatchInsert() throws Exception{
SqlSession session = null;
try{
long st = new Date().getTime();
session = MyBatisUtils.openSession();
List list = new ArrayList();
for (int i = 0; i < 10000; i++ ){           //执行时间:3160毫秒
//            for (int i = 0; i < 2; i++ ){          //执行时间:1970毫秒
Goods goods = new Goods();
goods.setTitle("测试商品"+ "i");
goods.setSubTitle("测试子标题"+ "i");
goods.setOriginalCost(300f + i);
goods.setCurrentPrice(500f + i);
goods.setDiscount(i * 0.0001f);
goods.setIsFreeDelivery(1);
goods.setCategoryId(43);
list.add(goods);
}
session.insert("goods.batchInsert", list);
session.commit();      // 提交事务
long et = new Date().getTime();
System.out.println("执行时间:" + (et - st) + "毫秒") ;
}catch(Exception e){
throw e;
}finally{
MyBatisUtils.closeSession(session);
}
}

7.2 批量删除

(1) 编写SQL标签
delete from t_goods where goods_id in
#{item}
(2)测试方法 testBatchDelete
@Test
public void testBatchDelete() throws Exception{
SqlSession session = null;
try{
long st = new Date().getTime();
session = MyBatisUtils.openSession();
List list = new ArrayList();
list.add(12685);
list.add(12684);
list.add(12683);
list.add(12682);
list.add(12681);
session.delete("goods.batchDelete", list);
session.commit();
long et = new Date().getTime();
System.out.println("执行时间:" + (et - st) + "毫秒") ;
}catch(Exception e){
throw e;
}finally{
MyBatisUtils.closeSession(session);
}
}

8. MyBatis 注解开发

        将xml代码放入程序中,开发更加方便

8.1 MyBatis 的常用注解

8.2 @Select

(1) 注释掉 mapper 标签

(2) 编写 GoodsDTO1 
package com.phdvb.mybatis.dto;
public class GoodsDTO1 {
private Integer goodsId;
private String title;
private Float currentPrice;
public GoodsDTO1() {
}
public Integer getGoodsId() {
return goodsId;
}
public void setGoodsId(Integer goodsId) {
this.goodsId = goodsId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Float getCurrentPrice() {
return currentPrice;
}
public void setCurrentPrice(Float currentPrice) {
this.currentPrice = currentPrice;
}
}
(3) 编写 GoodsDAO 接口
package com.phdvb.mybatis.dao;
import com.phdvb.mybatis.entity.Goods;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface GoodsDAO {
@Select(" select * from t_goods where current_price between #{min} and #{max} limit 0, #{limt}")
public List selectByPriceRange(@Param("min") Float min, @Param("max") Float max, @Param("limt") Integer limt);
}
(4)调整 mybatis-config.xml
-->-->
(5)  测试 @Select 注解
// 测试 @Select 注解
@Test
public void testAnnotationSelectRange() throws Exception{
SqlSession sqlSession = null;
try{
sqlSession = MyBatisUtils.openSession();
GoodsDAO goodsDAO = sqlSession.getMapper(GoodsDAO.class);
List list = goodsDAO.selectByPriceRange(100f, 500f, 20);
System.out.println(list.size());
}catch (Exception e){
throw e;
}finally{
MyBatisUtils.closeSession(sqlSession);
}
}

8.3 @Insert

(1)编写接口
@Insert("insert into t_goods(title, sub_title, original_cost, current_price, discount, is_free_delivery, category_id) values (#{title}, #{subTitle}, #{originalCost}, #{currentPrice}, #{discount}, #{isFreeDelivery}, #{categoryId})")
// 之前使用  获取id
@SelectKey(statement = "select last_insert_id()", before = false, keyProperty = "goodsId", resultType = Integer.class)
public int insert(Goods goods);
(2)编写测试类
// 测试 @Insert 注解
@Test
public void testInsert() throws Exception{
SqlSession sqlSession = null;
try{
sqlSession = MyBatisUtils.openSession();
Goods goods = new Goods();
goods.setTitle("测试Insert goods");
goods.setSubTitle("测试Insert Sub goods");
goods.setOriginalCost(200f);
goods.setCurrentPrice(100f);
goods.setDiscount(0.55f);
goods.setIsFreeDelivery(1);
goods.setCategoryId(43);
GoodsDAO goodsDAO = sqlSession.getMapper(GoodsDAO.class);
int num = goodsDAO.insert(goods);
sqlSession.commit();
System.out.println(goods.getGoodsId());
}catch (Exception e){
if(sqlSession != null){
sqlSession.rollback();
}
}finally{
MyBatisUtils.closeSession(sqlSession);
}
}
(3)测试testSelectAll()
@Test
public void testSelectAll() throws Exception{
SqlSession sqlSession = null;
try{
sqlSession = MyBatisUtils.openSession();
GoodsDAO goodsDAO = sqlSession.getMapper(GoodsDAO.class);
List list = goodsDAO.selectAll();
System.out.println(list.size());        //11936
}catch (Exception e){
throw e;
}finally {
MyBatisUtils.closeSession(sqlSession);
}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/910124.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

王者荣耀官方网站s网站优化

计算机室如何管理自身所存放着的大量的信息的呢&#xff1f;windows的磁盘管理程序为我们提供了一套严密而又高效的信息组织形式--硬盘上的信息是以文件的形式被管理的。 面向存储的文件技术 什么是文件&#xff1f;计算机中&#xff0c;一篇文章、一幅图片、一个程序等都是以文…

网站建网站深圳专业商城网站设计制作

正题 题目链接:https://www.luogu.com.cn/problem/P4593 题目大意 场上有若干只怪&#xff0c;最高的为nnn&#xff0c;每个怪血量不同&#xff0c;有mmm个血量不存在。 不停释放亵渎&#xff08;全场打一&#xff0c;如果有怪死亡就再次生效&#xff09;&#xff0c;每次一…

西宁做网站的好公司wordpress自定义背景

在数字化转型浪潮席卷全球的今天&#xff0c;区块链技术以其去中心化、透明性、不可篡改等独特优势&#xff0c;正逐步成为重塑各行各业信任机制与业务流程的关键力量。 近日&#xff0c;中国通信工业协会正式发布了《区块链服务 基于区块链的去中心化标识符技术要求》与《区块…

陆川建设局网站wordpress文本编辑插件

在当今社会&#xff0c;公共安全是国家发展的重要基石&#xff0c;也是人民安居乐业的基本保障。为了打造更高水平的平安中国&#xff0c;国家推出了意义深远的雪亮工程&#xff0c;并出台了一系列相关政策&#xff0c;为公共安全事业保驾护航。而互联网监控管理平台作为雪亮工…

北京公司建站模板错乱变装wordpress

目录 【1】用队列实现栈 思路分析 ​ 易错总结 Queue.c&Queue.h手撕队列 声明栈MyStack 创建&初始化栈myStackCreate 压栈myStackPush 出栈&返回栈顶元素myStackPop 返回栈顶元素myStackTop 判断栈空否myStackEmpty 释放空间myStackFree MyStack总代码…

xampp 开发网站wordpress国内打开慢

四年创作&#xff0c;心路历程 前言初识收获日常憧憬 前言 这是我在这个网站整理的笔记,有错误的地方请指出&#xff0c;关注我&#xff0c;接下来还会持续更新。 作者&#xff1a;神的孩子都在歌唱 前言 今天打开csdn&#xff0c;发现官方发送了一条私信,原来我已经在计算机这…

和县网站设计页面设计包括什么

批量查询邮政快递单号的物流信息&#xff0c;将提前签收件分析筛选出来。 所需工具&#xff1a; 一个【快递批量查询高手】软件 邮政快递单号若干 操作步骤&#xff1a; 步骤1&#xff1a;运行【快递批量查询高手】软件&#xff0c;并登录 步骤2&#xff1a;点击主界面左上角…

中国城乡建设部人力网站首页网站建设售后服务费包括哪些

图 基本介绍 表示方式 图的创建 from typing import Listclass Graph:vertex_list: List[str] [] # 存储顶点的数组edges: List[list] [] # 存储图中各条边的邻接矩阵num_edges: int 0 # 边的数总数def __init__(self, n: int):"""根据传入的顶点个数初始…

联想拯救者无法登录当前账户

联想拯救者无法登录当前账户 坑货联想具体病因: 更新后把账户文件夹(C:\User\你的账户文件夹)的权限给丢掉了,处于一种无法被访问、调用的状态。 电脑不能没有账户可读,于是在同级的User文件夹中生成了名为TEMP的…

Spark 性能优化全攻略:内存管理、shuffle 优化与参数调优 - 详解

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

站长之家站长工具无锡在线制作网站

其实在今天的运维领域&#xff0c;ITIL和DevOps之间的冲突还是蛮明显的&#xff0c;有些是表现在产品上&#xff0c;有些是表现在思维/理念上。ITIL在产品上以流程为核心目标的设计&#xff0c;很难满足自动化的要求&#xff0c;DevOps极力推崇工具/平台/自服务文化&#xff1b…

WPF二合一平板电脑上屏幕旋转时获取屏幕宽高问题

在二合一平板上面,屏幕旋转之后,屏幕的宽高会被改变,如果代码里面有用到屏幕宽高的地方可能会出错。 获取屏幕宽高位置可以通过可以通过如下几种方式获取/// <summary>/// 获取屏幕大小 /// </summary>…

以橙色为主的网站上海网页设计公司哪儿济南兴田德润有活动吗

SpringBootAdmin监控原理Actuator&#xff0c;自定义指标 文章目录 SpringBootAdmin监控原理Actuator&#xff0c;自定义指标actuator自定义info端点信息自定义Health端点信息自定义metrics端点信息端点的自定义 actuator JMX方式就是在cmd控制台输入jconsole&#xff0c;会弹出…

asp.net 制作网站教程推销产品怎么推广

前言 今天看到群里有人问”用matlab输出测试集的精度“&#xff0c;瞎试了一下&#xff0c;好像还成功了。主要还是依据前面所有在matlab中操作caffe的博客。 这里说一下&#xff1a;classification.m是适用单张图片的精度&#xff0c;类似于classification.exe的功能&#x…

衡水 网站开发wordpress 目录模板

正题 题目链接:https://www.51nod.com/Contest/Problem.html#contestProblemId1149 题目大意 nnn个数&#xff0c;求有多少种选择方案使选择的数乘机为kkk。 解题思路 显然kkk的质因数最多只有999个&#xff0c;我们将质因数进行dpdpdp。若选择的数的质因数刚好是kkk的质因数…

网站建设查看框架的源代码武威百度做网站多少钱

1.为啥主系统装了Ubuntu 由于公司发电脑了&#xff0c;我自己也有一台台式电脑&#xff0c;然后也想去折腾一下Ubuntu&#xff0c;就把自己的笔记本装成Ubuntu系统了&#xff0c; 我使用的是23.04的桌面版&#xff0c;带图形化界面的。我准备换回Windows 11了&#xff08;因为…

平面设计网站建设网站建设 宁夏

大家在使用Word邮件合并这个功能&#xff0c;比如制作席卡、贺卡、准考证、员工档案、成绩单、邀请函、名片等等&#xff0c;那就需要对图片路径进行转换处理&#xff0c;此脚本就是直接将图片的路径提取出来&#xff0c;并把内容放到txt格式的文本文档里&#xff0c;打开Excel…

怎么做公司网站需要什么科目应用公园是收费还是免费的

最小 API 并不是在 .NET 7 中才加入的&#xff0c;记得应该是在 .NET 6 中就已经提供&#xff0c;只是对我来说&#xff0c;到现在才开始使用。创建一个最小 API在 VS 2022 中创建 WebAPI 项目&#xff0c;不勾选使用控制器&#xff0c;创建出来的就是最小 API &#xff1a;不勾…

官方网站营销网站开发获取用户微信号登录

自动装配(autowiring)有助于减少甚至消除配置<property>元素和<constructor-arg>元素&#xff0c;让Spring自动识别如何装配Bean的依赖关系。 自动检测(autodiscovery)比自动装配更进了一步&#xff0c;让Spring能够自动识别哪些类需要被配置成Spring Bean&#xf…

实战:Android 自定义菊花加载框(带超时自动消失) - 教程

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …