首页 > 其他分享 >使用mybatis完成CRUD

使用mybatis完成CRUD

时间:2023-05-30 13:32:29浏览次数:45  
标签:car brand CRUD public sqlSession 完成 mybatis id

1. 什么是CRUD    17

C: Create 增

R: Retrieve 查(检索)

U: Update 改

D: Delete 删

2. insert   17

<insert id="insertCar">

insert into t_car(id,car_num,brand,guide_price,produce_time,car_type)

values(null,'1003','丰田霸道',30.0,'2000-10-11','燃油车');

</insert>


2.1 这样写的问题是  17

值 显然是写死到配置文件中的。

这个在实际开发中是不存在的。

一定是前端的form表单提交过来数据。然后将值传给sql语句。

2.2 例如:JDBC的代码是怎么写的?17

String sql = "insert into t_car(id,car_num,brand,guide_price,produce_time,car_type) values(null,?,?,?,?,?)";

ps.setString(1, xxx);

ps.setString(2, yyy);

....

2.3 在JDBC当中占位符采用的是?,在mybatis当中是什么呢?17

和?等效的写法是:#{}

在mybatis当中不能使用?占位符,必须使用 #{} 来代替JDBC当中的 ?

{} 和 JDBC当中的 ? 是等效的。

2.3.1 java程序中使用Map可以给SQL语句的占位符传值:17

Map<String, Object> map = new HashMap<>();

map.put("k1", "1111");

map.put("k2", "比亚迪汉");

map.put("k3", 10.0);

map.put("k4", "2020-11-11");

map.put("k5", "电车");


insert into t_car(id,car_num,brand,guide_price,produce_time,car_type) values(null,#{k1},#{k2},#{k3},#{k4},#{k5});

注意:#{这里写什么?写map集合的key,如果key不存在,获取的是null}

一般map集合的key起名的时候要见名知意。

map.put("carNum", "1111");

map.put("brand", "比亚迪汉2");

map.put("guidePrice", 10.0);

map.put("produceTime", "2020-11-11");

map.put("carType", "电车");

insert into t_car(id,car_num,brand,guide_price,produce_time,car_type) values(null,#{carNum},#{brand},#{guidePrice},#{produceTime},#{carType});

2.3.2 java程序中使用POJO类给SQL语句的占位符传值:18

Car car = new Car(null, "3333", "比亚迪秦", 30.0, "2020-11-11", "新能源");

注意:占位符#{},大括号里面写:pojo类的属性名

insert into t_car(id,car_num,brand,guide_price,produce_time,car_type)

values(null,#{carNum},#{brand},#{guidePrice},#{produceTime},#{carType})

2.3.2.1 把SQL语句写成这个德行:  18

insert into t_car(id,car_num,brand,guide_price,produce_time,car_type)

values(null,#{xyz},#{brand},#{guidePrice},#{produceTime},#{carType})

出现了什么问题呢?

There is no getter for property named 'xyz' in 'class com.powernode.mybatis.pojo.Car'

mybatis去找:Car类中的getXyz()方法去了。没找到。报错了。

2.3.2.1.1 怎么解决的?  18

可以在Car类中提供一个getXyz()方法。这样问题就解决了。

通过这个测试,得出一个结论:

严格意义上来说:如果使用POJO对象传递值的话,#{}这个大括号中到底写什么?

写的是get方法的方法名去掉get,然后将剩下的单词首字母小写,然后放进去。

例如:getUsername() --> #{username}

例如:getEmail() --> #{email}

....

也就是说mybatis在底层给?传值的时候,先要获取值,怎么获取的?

调用了pojo对象的get方法。例如:car.getCarNum(),car.getCarType(),car.getBrand()

3. delete   19

●需求:根据id删除数据

将id=14的数据删除。

实现:

int count = sqlSession.delete("deleteById", 14);

<delete id="deleteById">

delete from t_car where id = #{fdsfd}

</delete>

注意:如果占位符只有一个,那么#{}的大括号里可以随意。但是最好见名知意。

4. update   20

● ●需求:根据id修改某条记录。


实现:

<update id="updateById">

update t_car set

car_num=#{carNum},

brand=#{brand},

guide_price=#{guidePrice},

produce_time=#{produceTime},

car_type=#{carType}

where

id = #{id}

</update>


Car car = new Car(4L, "9999", "凯美瑞", 30.3, "1999-11-10", "燃油车");

int count = sqlSession.update("updateById", car);

5. select(查一个,根据主键查询的话,返回的结果一定是一个。)  21

● ●需求:根据id查询。

实现:

<select id="selectById" resultType="com.powernode.mybatis.pojo.Car">

select * from t_car where id = #{id}

</select>


Object car = sqlSession.selectOne("selectById", 1);

5.1 需要特别注意的是:  21

select标签中resultType属性,这个属性用来告诉mybatis,查询结果集封装成什么类型的java对象。你需要告诉mybatis。

resultType通常写的是:全限定类名。

Car{id=1, carNum='null', brand='宝马520Li', guidePrice=null, produceTime='null', carType='null'}

输出结果有点不对劲:

id和brand属性有值。

其他属性为null。

5.2 carNum以及其他的这几个属性没有赋上值的原因是什么?21

select * from t_car where id = 1

执行结果:

使用mybatis完成CRUD_mybatis

car_num、guide_price、produce_time、car_type这是查询结果的列名。

这些列名和Car类中的属性名对不上。

Car类的属性名:

carNum、guidePrice、produceTime、carType

5.2.1 那这个问题怎么解决呢?

select语句查询的时候,查询结果集的列名是可以使用as关键字起别名的。

<select id="selectById" resultType="com.powernode.mybatis.pojo.Car">

select

id,car_num as carNum,brand,guide_price as guidePrice,

produce_time as produceTime,

car_type as carType

from

t_car

where

id = #{id}

</select>

起别名之后:

+----+--------+-----------+------------+-------------+---------+

| id | carNum | brand     | guidePrice | produceTime | carType |

+----+--------+-----------+------------+-------------+---------+

|  1 | 1001   | 宝马520Li |      10.00 | 2020-10-11  | 燃油车  |

+----+--------+-----------+------------+-------------+---------+

6. select(查所有的)  22

<select id="selectAll" resultType="com.powernode.mybatis.pojo.Car">

select

id,car_num as carNum,brand,guide_price as guidePrice,

produce_time as produceTime,

car_type as carType

from

t_car

</select>


List<Object> cars = sqlSession.selectList("selectAll");

注意:resultType还是指定要封装的结果集的类型。不是指定List类型,是指定List集合中元素的类型。

selectList方法:mybatis通过这个方法就可以得知你需要一个List集合。它会自动给你返回一个List集合。

7. namespace  23

在sql mapper.xml文件当中有一个namespace,这个属性是用来指定命名空间的。用来防止id重复。

怎么用?

在xml文件中:

<mapper namespace="aaaaaaaaa">

<select id="selectAll" resultType="com.powernode.mybatis.pojo.Car">

select

id,car_num as carNum,brand,guide_price as guidePrice,

produce_time as produceTime,

car_type

from

t_car

</select>

</mapper>

在java程序中的写法:

List<Object> cars = sqlSession.selectList("aaaaaaaaa.selectAll");

实际上,本质上,mybatis中的sqlId的完整写法:namespace.id

在核心文件mybatis-config.xml

<mapper resource="UserMapper.xml"/>

main代码在com.powernode.mybatis.test

testNamespace

public class CarMapperTest {
//研究namespace  23
//这个属性是用来指定命名空间的。用来防止id重复。
@Test
public void testNamespace(){
SqlSession sqlSession = SqlSessionUtil.openSession();
//List<Object> cars = sqlSession.selectList("selectAll");
// 正确完整的写法:namespace.id
List<Object> cars = sqlSession.selectList("aaaaaa.selectAll");
cars.forEach(car-> System.out.println(car));
sqlSession.close();
}
}

resources目录下

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="aaaaaa">  <!--namespace这个属性是用来指定命名空间的。用来防止id重复。-->

<!--查询所有数据  20-->
<select id="selectAll" resultType="com.powernode.mybatis.pojo.Car">
select
id,car_num as carNum,brand,guide_price as guidePrice,
produce_time as produceTime,
car_type
from
t_car
</select>

</mapper>

8. CRUD代码

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.powernode</groupId>
<artifactId>course4</artifactId>
<version>1.0-SNAPSHOT</version>

<!--    打包方式jar-->
<packaging>jar</packaging>

<!--    依赖-->
<dependencies>
<!--mybatis核⼼依赖-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.10</version>
</dependency>
<!--mysql驱动依赖-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.30</version>
</dependency>

<!--            junit单元测试依赖   13-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>

<!--        引入logback的依赖,这个入职框架实现了slf4j规范-->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.11</version>
</dependency>


</dependencies>

<properties>
<!--    编译代码使用的jdk版本-->
<maven.compiler.source>1.8</maven.compiler.source>
<!--    运行程序使用的jdk版本-->
<maven.compiler.target>1.8</maven.compiler.target>
</properties>



</project>

main代码在com.powernode.mybatis.pojo

Car

package com.powernode.mybatis.pojo;

//这是一个封装汽车相关的javabean  18
public class Car {
// 数据库表当中的字段应该和pojo类的属性一一对应。
// 建议使用包装类,这样可以防止null的问题。
private Long id;
private String carNum;
private String brand;
private Double guidePrice;
private String produceTime;
private String carType;

@Override
public String toString() {
return "Car{" +
"id=" + id +
", carNum='" + carNum + '\'' +
", brand='" + brand + '\'' +
", guidePrice=" + guidePrice +
", produceTime='" + produceTime + '\'' +
", carType='" + carType + '\'' +
'}';
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getCarNum() {
return carNum;
}

/*public String getXyz() {
return carNum;
}*/

public void setCarNum(String carNum) {
this.carNum = carNum;
}

public String getBrand() {
return brand;
}

public void setBrand(String brand) {
this.brand = brand;
}

public Double getGuidePrice() {
return guidePrice;
}

public void setGuidePrice(Double guidePrice) {
this.guidePrice = guidePrice;
}

public String getProduceTime() {
return produceTime;
}

public void setProduceTime(String produceTime) {
this.produceTime = produceTime;
}

public String getCarType() {
return carType;
}

public void setCarType(String carType) {
this.carType = carType;
}

public Car(Long id, String carNum, String brand, Double guidePrice, String produceTime, String carType) {
this.id = id;
this.carNum = carNum;
this.brand = brand;
this.guidePrice = guidePrice;
this.produceTime = produceTime;
this.carType = carType;
}

public Car() {
}
}

com.powernode.mybatis.utils

工具类SqlSessionUtil

package com.powernode.mybatis.utils;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;

//mybatis的工具类  16
public class SqlSessionUtil {
// 工具类的构造方法一般都是私有化的。
// 工具类中所有的方法都是静态的,直接采用类名即可调用。不需要new对象。
// 为了防止new对象,构造方法私有化。
private SqlSessionUtil(){}

private static SqlSessionFactory sqlSessionFactory;

// 类加载时执行
// SqlSessionUtil工具类在进行第一次加载的时候,解析mybatis-config.xml文件。创建SqlSessionFactory对象。
static {
try {
sqlSessionFactory = new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream("mybatis-config.xml"));
} catch (IOException e) {
throw new RuntimeException(e);
}
}

/*public static SqlSession openSession(){
SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder();
// SqlSessionFactory对象:一个SqlSessionFactory对应一个environment,一个environment通常是一个数据库。
SqlSessionFactory sqlSessionFactory = sqlSessionFactoryBuilder.build(Resources.getResourceAsStream("mybatis-config.xml"));
SqlSession sqlSession = sqlSessionFactory.openSession();
return sqlSession;
}*/

/**
* 获取会话对象。
* @return 会话对象
*/
public static SqlSession openSession(){
return sqlSessionFactory.openSession();
}
}

resources目录下

核心文件mybatis-config.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>

<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/powernode"/>
<property name="username" value="root"/>
<property name="password" value="lzl"/>
</dataSource>
</environment>
</environments>
<mappers>
<!--执行XxxMapper.xml文件的路径     8-->
<!--resource属性自动会从类的根路径下开始查找资源。-->
<mapper resource="CarMapper.xml"/>
<mapper resource="UserMapper.xml"/>
</mappers>
</configuration>

日志文件logback.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义⽇志⽂件的存储地址-->
<property name="LOG_HOME" value="/home"/>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示⽇期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:⽇志消息,%n是换⾏符-->
<pattern>[%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>

<!--mybatis log configure-->
<logger name="com.apache.ibatis" level="TRACE"/>
<logger name="java.sql.Connection" level="DEBUG"/>
<logger name="java.sql.Statement" level="DEBUG"/>
<logger name="java.sql.PreparedStatement" level="DEBUG"/>
<!-- ⽇志输出级别,logback⽇志级别包括五个:TRACE < DEBUG < INFO < WARN < ERROR -->
<root level="DEBUG">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE"/>
</root>
</configuration>

CarMapper.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="jkljkljkl">

<!--insert语句,id是这条SQL语句的唯一标识。这个id就代表了这条SQL语句。   17-->
<insert id="insertCar">

<!--增加数据   18-->
<!--insert into t_car(id,car_num,brand,guide_price,produce_time,car_type)
values(null,#{k1},#{k2},#{k3},#{k4},#{k5});-->

<!--insert into t_car(id,car_num,brand,guide_price,produce_time,car_type)
values(null,#{carNum},#{brand},#{guidePrice},#{produceTime},#{carType});-->

<!--增加数据  18-->
insert into t_car(id,car_num,brand,guide_price,produce_time,car_type)
values(null,#{carNum},#{brand},#{guidePrice},#{produceTime},#{carType});

</insert>

<!--删除数据  19-->
<delete id="deleteById">
delete from t_car where id = #{id}
</delete>

<!--更改数据  20-->
<update id="updateById">
update t_car set
car_num=#{carNum},
brand=#{brand},
guide_price=#{guidePrice},
produce_time=#{produceTime},
car_type=#{carType}
where
id = #{id}
</update>

<!--查询一条数据  20-->
<select id="selectById" resultType="com.powernode.mybatis.pojo.Car">
<!--select * from t_car where id = #{id}-->
<!--因为javabean中的属性名和表中的字段名不一致会导致有的查询结果为空,所以我们利用as起别名-->
select
id,car_num as carNum,brand,guide_price as guidePrice,
produce_time as produceTime,
car_type as carType
from
t_car
where
id = #{id}
</select>

<!--查询所有数据  20-->
<select id="selectAll" resultType="com.powernode.mybatis.pojo.Car">
select
id,car_num as carNum,brand,guide_price as guidePrice,
produce_time as produceTime,
car_type as carType
from
t_car
</select>

</mapper>

test代码在com.powernode.mybatis.test

CarMapperTest

package com.powernode.mybatis.test;

import com.powernode.mybatis.pojo.Car;
import com.powernode.mybatis.utils.SqlSessionUtil;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

//使用mybatis完成CRUD  17
public class CarMapperTest {

//查询多个数据  22
@Test
public void testSelectAll(){
SqlSession sqlSession = SqlSessionUtil.openSession();
// 执行SQL语句
//List cars = sqlSession.selectList("selectAll");
List cars = sqlSession.selectList("selectAll");
// 遍历
//这个是lamda表达式car -> System.out.println(car)
cars.forEach(car -> System.out.println(car));
sqlSession.close();
}

//查询一条数据  21
@Test
public void testSelectById(){
SqlSession sqlSession = SqlSessionUtil.openSession();

// 执行DQL语句。查询。根据id查询。返回结果一定是一条。
// mybatis底层执行了select语句之后,一定会返回一个结果集对象:ResultSet
// JDBC中叫做ResultSet,接下来就是mybatis应该从ResultSet中取出数据,封装java对象。
Object car = sqlSession.selectOne("selectById", 1);
System.out.println(car);

sqlSession.close();
}

//更改数据   20
@Test
public void testUpdateById(){
SqlSession sqlSession = SqlSessionUtil.openSession();
// 准备数据
//这个4L是idL代表Long类型
Car car = new Car(6L, "9999", "凯美瑞", 30.3, "1999-11-10", "燃油车");

// 执行SQL语句
int count = sqlSession.update("updateById",car);
System.out.println(count);
sqlSession.commit();
sqlSession.close();
}


//删除数据   19
@Test
public void testDeleteById(){
SqlSession sqlSession = SqlSessionUtil.openSession();
// 执行SQL语句
//int count = sqlSession.delete("deleteById", 14);
int count = sqlSession.delete("deleteById", 30);
System.out.println(count);
sqlSession.commit();
sqlSession.close();
}

//使用pojo封装向数据库中加入数据18
@Test
public void testInsertCarByPOJO(){
SqlSession sqlSession = SqlSessionUtil.openSession();
//封装数据
Car car = new Car(null, "3333", "比亚迪秦", 30.0, "2020-11-11", "新能源");

//执行sql
int count = sqlSession.insert("insertCar",car);
System.out.println("受影响行数==~~~~"+count);
sqlSession.commit();
sqlSession.close();
}

//向数据库中加入数据   17
@Test
public void testInsertCar(){
SqlSession sqlSession = SqlSessionUtil.openSession();
// 前端传过来数据了。
// 这个对象我们先使用Map集合进行数据的封装。
Map map = new HashMap<>();
/*map.put("k1", "1111");
map.put("k2", "比亚迪汉");
map.put("k3", 10.0);
map.put("k4", "2020-11-11");
map.put("k5", "电车");*/

map.put("carNum", "1111");
map.put("brand", "比亚迪汉2");
map.put("guidePrice", 10.0);
map.put("produceTime", "2020-11-11");
map.put("carType", "电车");

// 执行SQL语句
// insert方法的参数:
// 第一个参数:sqlId,从CarMapper.xml文件中复制。
// 第二个参数:封装数据的对象。
int count = sqlSession.insert("insertCar",map);
System.out.println("受影响行数==~~~~"+count);
sqlSession.commit();
sqlSession.close();
}


}

标签:car,brand,CRUD,public,sqlSession,完成,mybatis,id
From: https://blog.51cto.com/u_15784725/6378179

相关文章

  • vue前端的avue-crud操作
     1、在js中获取某个字段的属性,或设置字段的值:constcolumn=this.findObject(this.option.column,"parentId");column.disabled=true;//设置为禁用此字段column.value='1';//设置parentId字段的value值console.log("column属性:",co......
  • 最全面的Mybatis面试八股文
    Mybatis是什么?MyBatis框架是一个开源的数据持久层框架。它的内部封装了通过JDBC访问数据库的操作,支持普通的SQL查询、存储过程和高级映射,几乎消除了所有的JDBC代码和参数的手工设置以及结果集的检索。MyBatis作为持久层框架,其主要思想是将程序中的大量SQL语句剥离出来,配置在配......
  • JS判断视频Video的播放、暂停、结束完成及获取长度事件监听处理
    在日常应用场景中,可能会遇到这么一个情况,需要判断用户是否完整的观看完了一部视频,在这个场景中,和视频相关的事件大体涉及到几个部分,获取视频长度,视频开始播放,暂停播放和播放结束,下面来看下如何通过JavaScript来监听获取视频的这几种状态。(1)html页面视频标签大体如下<videoid="v......
  • mybatis配置多数据源
    yml中配置mybatis的日志输出信息mybatis:#springboot集成mybatis的方式打印sqlconfiguration:log-impl:org.apache.ibatis.logging.stdout.StdOutImplmaven引入相关的配置<dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>my......
  • 开发手记:MyBatis的mapper文件的中SQL符号转义
    字符转义问题在MaBatis的XML文件中编写SQL语句时,<符号会出现转义问题,例如:<!--查询指定月份内的订单--><selectid="queryInRange"resultType="OrderEntity"> SELECT*FROMorder WHEREcreate_time>DATE_SUB(NOW(),INTERVAL#{month}MONTH) ANDuser_i......
  • win10 修改IP错误:出现一个意外情况,不能完成所有你在设置中所要求的更改
    注意:以下命令要以管理员身份运行cmd修改自动获取IP和DNS:netshinterfaceipsetaddressname="以太网"source=dhcpnetshinterfaceipsetdnsname="以太网"source=dhcp“以太网”是网卡适配器的名字,譬如我电脑上有名为WLAN和以太网的两个网络适配器,我这里选择......
  • Mybatis-plus 简单使用
    Mybatis-plus特点介绍:1、无侵入:只做增强不做改变,引入它不会对现有工程产生影响2、强大的CRUD操作:内置通用Mapper、Service,仅仅通过少量配置即可实现单表大部分CRUD操作,更有强大的条件构造器,满足各类使用需求。3、支持Lambda形式调用:通过Lambda表达式,方便编......
  • 两天,总计六个小时,中移在线核心业务系统顺利完成1050套欧拉操作系统迁移上线
    摘要:历时两天,总计六个小时,中国移动在线营销服务中心(简称中移在线)正式启动内部核心业务系统全网呼叫平台的迁移工作。首批1050套操作系统完成从CentOS(系统版本7.2、7.4和7.6)到 openEuler高效平滑迁移。中移在线拥有全球最大的呼叫平台,采用“中心+边缘”的部署架构,按照“控制集中,......
  • 计算机存储体系中主存地址和 Cache 地址之间的转换工作由谁完成
    在存储体系中,位于主存与CPU之间的高速缓存(Cache)是用于存放主存中部分信息的副本,目的是提高处理器对数据的访问速度。主存地址与Cache地址之间的转换工作由一个硬件模块称为Cache控制器(CacheController)完成。Cache控制器是一个专门设计的硬件模块,通常集成在CPU芯片内部或者作为独......
  • mybatis查询时实体类属性名与表的字段名不一致的解决方法
    目录1、设置查询字段别名法2、在mybatis的核心配置文件中设置全局配置信息mapUnderscoreToCamelCase为true,将表中字段的下划线自动转换为驼峰3、将select语句的resultType换为resultMap,在resultMap中配置字段名和属性值的对应关系———————————————— 问题描......