Spring Boot入门系列之:三、Spring Boot整合Mybatis

spring boot+mybatis整合 LZ今天自己搭建了下Spring boot+Mybatis,比原来的Spring+SpringMVC+Mybatis简单好多。其实只用Spring boot也可以开发,但是对于多表多条件分页查询,Spring boot就有点力不从心了,所以LZ把Mybatis整合进去,不得不说,现在的框架搭建真的是方便。话不多说,进入正题。 一、java web开发环境搭建   网上有很多教程, 二、Spring boot搭建   1、Intellij idea菜单栏File->new->project 阅读详情

spring-boot-mybatis

开发环境

开发工具: Intellij IDEA 2018.2.6

springboot: 2.0.7.RELEASE

jdk: 1.8.0_192

maven: 3.6.0

mybatis: 3.4.6

mybatis 简介

什么是 MyBatis ?

MyBatis 是一款优秀的持久层框架,它支持定制化 SQL、存储过程以及高级映射。MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集。MyBatis 可以使用简单的 XML 或注解来配置和映射原生信息,将接口和 Java 的 POJOs(Plain Old Java Objects,普通的 Java对象)映射成数据库中的记录。

What is MyBatis-Spring?

MyBatis-Spring 会帮助你将 MyBatis 代码无缝地整合到 Spring 中。 使用这个类库中的类, Spring 将会加载必要的 MyBatis 工厂类和 session 类。 这个类库也提供一个简单的方式来注入 MyBatis 数据映射器和 SqlSession 到业务层的 bean 中。 而且它也会处理事务, 翻译 MyBatis 的异常到 Spring 的 DataAccessException 异常(数据访问异常,译者注)中。最终,它并 不会依赖于 MyBatis,Spring 或 MyBatis-Spring 来构建应用程序代码。

mybatis的常用配置

设置参数描述有效值默认值
cacheEnabled全局地开启或关闭配置文件中的所有映射器已经配置的任何缓存。true | falsetrue
lazyLoadingEnabled延迟加载的全局开关。当开启时,所有关联对象都会延迟加载。 特定关联关系中可通过设置fetchType属性来覆盖该项的开关状态。true | falsefalse
aggressiveLazyLoading当开启时,任何方法的调用都会加载该对象的所有属性。否则,每个属性会按需加载(参考lazyLoadTriggerMethods).true | falsefalse (true in ≤3.4.1)
multipleResultSetsEnabled是否允许单一语句返回多结果集(需要兼容驱动)。true | falsetrue
useColumnLabel使用列标签代替列名。不同的驱动在这方面会有不同的表现, 具体可参考相关驱动文档或通过测试这两种不同的模式来观察所用驱动的结果。true | falsetrue
useGeneratedKeys允许 JDBC 支持自动生成主键,需要驱动兼容。 如果设置为 true 则这个设置强制使用自动生成主键,尽管一些驱动不能兼容但仍可正常工作(比如 Derby)。true | falseFalse
autoMappingBehavior指定 MyBatis 应如何自动映射列到字段或属性。 NONE 表示取消自动映射;PARTIAL 只会自动映射没有定义嵌套结果集映射的结果集。 FULL 会自动映射任意复杂的结果集(无论是否嵌套)。NONE, PARTIAL, FULLPARTIAL
autoMappingUnknownColumnBehavior指定发现自动映射目标未知列(或者未知属性类型)的行为。NONE: 不做任何反应WARNING: 输出提醒日志 ('org.apache.ibatis.session.AutoMappingUnknownColumnBehavior'的日志等级必须设置为 WARN)FAILING: 映射失败 (抛出 SqlSessionException)NONE, WARNING, FAILINGNONE
defaultExecutorType配置默认的执行器。SIMPLE 就是普通的执行器;REUSE 执行器会重用预处理语句(prepared statements); BATCH 执行器将重用语句并执行批量更新。SIMPLE REUSE BATCHSIMPLE
defaultStatementTimeout设置超时时间,它决定驱动等待数据库响应的秒数。任意正整数Not Set (null)
defaultFetchSize为驱动的结果集获取数量(fetchSize)设置一个提示值。此参数只可以在查询设置中被覆盖。任意正整数Not Set (null)
safeRowBoundsEnabled允许在嵌套语句中使用分页(RowBounds)。如果允许使用则设置为false。true | falseFalse
safeResultHandlerEnabled允许在嵌套语句中使用分页(ResultHandler)。如果允许使用则设置为false。true | falseTrue
mapUnderscoreToCamelCase是否开启自动驼峰命名规则(camel case)映射,即从经典数据库列名 A_COLUMN 到经典 Java 属性名 aColumn 的类似映射。true | falseFalse
localCacheScopeMyBatis 利用本地缓存机制(Local Cache)防止循环引用(circular references)和加速重复嵌套查询。 默认值为 SESSION,这种情况下会缓存一个会话中执行的所有查询。 若设置值为 STATEMENT,本地会话仅用在语句执行上,对相同 SqlSession 的不同调用将不会共享数据。SESSION | STATEMENTSESSION
jdbcTypeForNull当没有为参数提供特定的 JDBC 类型时,为空值指定 JDBC 类型。 某些驱动需要指定列的 JDBC 类型,多数情况直接用一般类型即可,比如 NULL、VARCHAR 或 OTHER。JdbcType 常量. 大多都为: NULL, VARCHAR and OTHEROTHER
lazyLoadTriggerMethods指定哪个对象的方法触发一次延迟加载。用逗号分隔的方法列表。equals,clone,hashCode,toString
defaultScriptingLanguage指定动态 SQL 生成的默认语言。一个类型别名或完全限定类名。org.apache.ibatis.scripting.xmltags.XMLLanguageDriver
defaultEnumTypeHandler指定 Enum 使用的默认 TypeHandler 。 (从3.4.5开始)一个类型别名或完全限定类名。org.apache.ibatis.type.EnumTypeHandler
callSettersOnNulls指定当结果集中值为 null 的时候是否调用映射对象的 setter(map 对象时为 put)方法,这对于有 Map.keySet() 依赖或 null 值初始化的时候是有用的。注意基本类型(int、boolean等)是不能设置成 null 的。true | falsefalse
returnInstanceForEmptyRow当返回行的所有列都是空时,MyBatis默认返回null。 当开启这个设置时,MyBatis会返回一个空实例。 请注意,它也适用于嵌套的结果集 (i.e. collectioin and association)。(从3.4.2开始)true | falsefalse
logPrefix指定 MyBatis 增加到日志名称的前缀。任何字符串Not set
logImpl指定 MyBatis 所用日志的具体实现,未指定时将自动查找。SLF4J | LOG4J | LOG4J2 | JDK_LOGGING | COMMONS_LOGGING | STDOUT_LOGGING | NO_LOGGINGNot set
proxyFactory指定 Mybatis 创建具有延迟加载能力的对象所用到的代理工具。CGLIB | JAVASSISTJAVASSIST (MyBatis 3.3 or above)
vfsImpl指定VFS的实现自定义VFS的实现的类全限定名,以逗号分隔。Not set
useActualParamName允许使用方法签名中的名称作为语句参数名称。 为了使用该特性,你的工程必须采用Java 8编译,并且加上-parameters选项。(从3.4.1开始)true | falsetrue
configurationFactory指定一个提供Configuration实例的类。 这个被返回的Configuration实例用来加载被反序列化对象的懒加载属性值。 这个类必须包含一个签名方法static Configuration getConfiguration(). (从 3.2.3 版本开始)类型别名或者全类名.Not set

Mybatis对应的jdbcType数据类型

类型处理器Java 类型JDBC 类型
BooleanTypeHandlerjava.lang.Boolean, boolean数据库兼容的 BOOLEAN
ByteTypeHandlerjava.lang.Byte, byte数据库兼容的 NUMERIC 或 BYTE
ShortTypeHandlerjava.lang.Short, short数据库兼容的 NUMERIC 或 SHORT INTEGER
IntegerTypeHandlerjava.lang.Integer, int数据库兼容的 NUMERIC 或 INTEGER
LongTypeHandlerjava.lang.Long, long数据库兼容的 NUMERIC 或 LONG INTEGER
FloatTypeHandlerjava.lang.Float, float数据库兼容的 NUMERIC 或 FLOAT
DoubleTypeHandlerjava.lang.Double, double数据库兼容的 NUMERIC 或 DOUBLE
BigDecimalTypeHandlerjava.math.BigDecimal数据库兼容的 NUMERIC 或 DECIMAL
StringTypeHandlerjava.lang.StringCHAR, VARCHAR
ClobReaderTypeHandlerjava.io.Reader-
ClobTypeHandlerjava.lang.StringCLOB, LONGVARCHAR
NStringTypeHandlerjava.lang.StringNVARCHAR, NCHAR
NClobTypeHandlerjava.lang.StringNCLOB
BlobInputStreamTypeHandlerjava.io.InputStream-
ByteArrayTypeHandlerbyte[]数据库兼容的字节流类型
BlobTypeHandlerbyte[]BLOB, LONGVARBINARY
DateTypeHandlerjava.util.DateTIMESTAMP
DateOnlyTypeHandlerjava.util.DateDATE
TimeOnlyTypeHandlerjava.util.DateTIME
SqlTimestampTypeHandlerjava.sql.TimestampTIMESTAMP
SqlDateTypeHandlerjava.sql.DateDATE
SqlTimeTypeHandlerjava.sql.TimeTIME
ObjectTypeHandlerAnyOTHER 或未指定类型
EnumTypeHandlerEnumeration TypeVARCHAR-任何兼容的字符串类型,存储枚举的名称(而不是索引)
EnumOrdinalTypeHandlerEnumeration Type任何兼容的 NUMERIC 或 DOUBLE 类型,存储枚举的索引(而不是名称)
InstantTypeHandlerjava.time.InstantTIMESTAMP
LocalDateTimeTypeHandlerjava.time.LocalDateTimeTIMESTAMP
LocalDateTypeHandlerjava.time.LocalDateDATE
LocalTimeTypeHandlerjava.time.LocalTimeTIME
OffsetDateTimeTypeHandlerjava.time.OffsetDateTimeTIMESTAMP
OffsetTimeTypeHandlerjava.time.OffsetTimeTIME
ZonedDateTimeTypeHandlerjava.time.ZonedDateTimeTIMESTAMP
YearTypeHandlerjava.time.YearINTEGER
MonthTypeHandlerjava.time.MonthINTEGER
YearMonthTypeHandlerjava.time.YearMonthVARCHAR or LONGVARCHAR
JapaneseDateTypeHandlerjava.time.chrono.JapaneseDateDATE

搭建项目

  • 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">

    <artifactId>spring-boot-mybatis</artifactId>
    <groupId>com.andy</groupId>
    <version>1.0.7.RELEASE</version>
    <modelVersion>4.0.0</modelVersion>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.spring.platform</groupId>
                <artifactId>platform-bom</artifactId>
                <version>Cairo-SR6</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>


    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.3.2</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.47</version>
        </dependency>


    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.0.3.RELEASE</version>
                <configuration>
                    <!--<mainClass>${start-class}</mainClass>-->
                    <layout>ZIP</layout>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

  • application.yml
server:
  port: 8081
  servlet:
    context-path: /
# spring-boot 连接 mysql 配置
spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://host:3306/boot?useSSL=false&characterEncoding=utf8&allowMultiQueries=true
    username: root
    password: root

# mybatis-springBoot 配置
mybatis:
  configuration:
    # 全局映射器启用缓存
    cache-enabled: true
    # 当启用时,有延迟加载属性的对象在被调用时将会完全加载任意属性。否则,每种属性将会按需要加载。
    aggressive-lazy-loading: false
    # 全局启用或禁用延迟加载。当禁用时,所有关联对象都会即时加载
    lazy-loading-enabled: false
    # 对于批量更新操作缓存SQL以提高性能
    default-executor-type: reuse
    # 允许返回不同的结果集以达到通用的效果
    multiple-result-sets-enabled: true
    # 数据库执行超时时间
    default-statement-timeout: 25000
    # 打印sql语句
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
    # 允许 JDBC 支持自动生成主键,需要驱动兼容。 如果设置为 true 则这个设置强制使用自动生成主键
    use-generated-keys: true
    # 设置但JDBC类型为空时,某些驱动程序 要指定值,default:OTHER,插入空值时不需要指定类型
    jdbc-type-for-null: null
    # 使用驼峰命名法转换字段
    map-underscore-to-camel-case: true
    # 指定 MyBatis 如何自动映射 数据基表的列 NONE:不隐射 PARTIAL:部分  FULL:全部
    auto-mapping-behavior: partial
    # 是否可以使用列的别名 (取决于驱动的兼容性) default:true
    use-column-label: true
    # 指定 Mybatis 创建具有延迟加载能力的对象所用到的代理工具。CGLIB|JAVASSIST, default(JAVASSIST)
    proxy-factory: CGLIB
    # 指定 MyBatis 增加到日志名称的前缀。任何字符串
    log-prefix: test
  mapper-locations: classpath:mybatis/mapper/*.xml
  type-aliases-package: com.andy.mapper
  executor-type: reuse

  • 启动类
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * <p>
 *
 * @author Leone
 * @since 2018-03-02
 **/
@MapperScan(basePackages = "com.andy.mybatis.mapper")
@SpringBootApplication
public class MybatisApplication {
    public static void main(String[] args) {
        SpringApplication.run(MybatisApplication.class, args);
    }
}
  • UserController.java

import com.andy.mybatis.entity.User;
import com.andy.mybatis.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *
 * @author Leone
 * @since 2018-03-02
 **/
@RestController
@RequestMapping("/api/user")
public class UserController {

    @Resource
    private UserService userService;

    @PostMapping
    public int insert(@RequestBody User user) {
        return userService.insert(user);
    }

    @PostMapping("/batch")
    public int insertBatch(@RequestBody List<User> user) {
        return userService.insertBatch(user);
    }

    @DeleteMapping
    public int deleteById(@RequestParam Long userId) {
        return userService.delete(userId);
    }

    @DeleteMapping("/batch")
    public int deleteByIds(@RequestParam List<Long> userIds) {
        return userService.deleteByIds(userIds);
    }

    @GetMapping("/page")
    public List<User> selectList(@RequestParam Integer start, @RequestParam Integer size) {
        return userService.page(start, size);
    }

    @GetMapping("/{userId}")
    public User selectById(@PathVariable("userId") Long userId) {
        return userService.selectById(userId);
    }

    @PutMapping
    public int update(@RequestBody User user) {
        return userService.update(user);
    }

    @PutMapping("/batch")
    public int updateBatch(@RequestBody List<User> users) {
        return userService.updateBatch(users);
    }

}

  • User.java
import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 *
 * @author Leone
 * @since 2018-03-02
 **/
public class User implements Serializable {

    private Long userId;

    private String account;

    private String password;

    private String description;

    private Integer age;

    private Date createTime;

    private boolean deleted;

    public User() {
    }

    public User(Long userId, String account, String password, String description, Integer age, Date createTime, Boolean deleted) {
        this.userId = userId;
        this.account = account;
        this.password = password;
        this.description = description;
        this.age = age;
        this.createTime = createTime;
        this.deleted = deleted;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public boolean isDeleted() {
        return deleted;
    }

    public void setDeleted(boolean deleted) {
        this.deleted = deleted;
    }
}

  • UserMapper.java

import com.andy.mybatis.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 *
 * @author Leone
 * @since 2018-03-02
 **/
@Mapper
public interface UserMapper {

    @Insert("insert into t_user(`account`, `password`, `age`, `description`, `deleted`, `create_time`) values (#{account},#{password},#{age},#{description},#{deleted},#{createTime})")
    int insert(User user);

    @Insert({"<script>" +
            "insert into t_user(`account`, `password`, `age`, `description`, `deleted`, `create_time`) values" +
            "<foreach collection=\"users\" item=\"user\" separator=\",\">" +
            "(#{user.account}, #{user.password}, #{user.age}, #{user.description}, #{user.deleted}, #{user.createTime}) " +
            "</foreach>" +
            "</script>"})
    int insertBatch(@Param("users") List<User> users);


    @Delete("delete from t_user where user_id = #{userId}")
    int deleteByUserId(@Param("userId") Long userId);

    @Delete("<script>" +
            "delete from t_user where user_id in " +
            "<foreach item='item' index='index' collection='userIds' open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach>" +
            "</script>")
    int deleteByUserIds(@Param("userIds") List<Long> userIds);


    @Select("select * from t_user where user_id = #{userId}")
    User findByUserId(@Param("userId") Long userId);

    @Select("select * from t_user limit ${start}, ${size}")
    List<User> page(@Param("start") int start, @Param("size") int size);


    @Update({"update t_user set account=#{user.account}, password=#{user.password}, age=#{user.age}, description=#{user.description}, create_time=#{user.createTime, jdbcType=TIMESTAMP}, deleted=#{user.deleted} where user_id = #{user.userId}"})
    int update(@Param("user") User user);

    @Update({"<script>" +
            "<foreach collection=\"users\" item=\"item\" separator=\";\">" +
            " update t_user set" +
            " account=#{item.account}," +
            " password=#{item.password}," +
            " age=#{item.age}," +
            " description=#{item.description}," +
            " create_time=#{item.createTime}," +
            " deleted=#{item.deleted}" +
            " where user_id=#{item.userId}" +
            "</foreach>" +
            "</script>"})
    int updateBatch(@Param("users") List<User> users);

}

  • UserService.java

import com.andy.mybatis.entity.User;
import com.andy.mybatis.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *
 * @author Leone
 * @since 2018-03-02
 **/
@Slf4j
@Service
public class UserService {

    @Resource
    private UserMapper userMapper;


    /**
     * 插入
     *
     * @param user
     * @return
     */
    public int insert(User user) {
        return userMapper.insert(user);
    }

    /**
     * 批量插入
     *
     * @param user
     * @return
     */
    public int insertBatch(List<User> user) {
        return userMapper.insertBatch(user);
    }


    /**
     * 更新
     *
     * @param user
     * @return
     */
    public int update(User user) {
        return userMapper.update(user);
    }

    /**
     * 批量更新
     *
     * @param users
     * @return
     */
    public int updateBatch(List<User> users) {
        return userMapper.updateBatch(users);
    }


    /**
     * 分页
     *
     * @param start
     * @param size
     * @return
     */
    public List<User> page(Integer start, Integer size) {
        return userMapper.page(start, size);
    }


    /**
     * 根据主键删除
     *
     * @param userId
     */
    public int delete(Long userId) {
        return userMapper.deleteByUserId(userId);
    }

    /**
     * 批量删除
     *
     * @param userIds
     */
    public int deleteByIds(List<Long> userIds) {
        return userMapper.deleteByUserIds(userIds);
    }

    public User selectById(Long userId) {
        return userMapper.findByUserId(userId);
    }
}

传送门

Spring Boot 整合 MyBatis 快速入门超详教程 快速入门 Spring Boot 和 MyBatis! 阅读详情

相关推荐

Spring Boot 整合 MyBatis

前言 下面就讲解下 Springboot 如何整合 MyBatis,这里使用的是xml配置SQL而不是用注解。主要是 SQL 和业务代码应该隔离,方便和 DBA 校对 SQL。 项目源代码 https://github.com/JasperZXY/TestSpringCloud/tree/master/boot-feature 由于我很多功能放在同一个项目里面,所以代码看起

蓦然回首一笑 4755

《Spring事务的陷阱(3)》中的现象与myBatis的执行器参数

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34162228的博客 273

Spring Boot入门(12):从零开始!轻松掌握Spring Boot整合MyBatis-Plus的最佳实践!

一文吃透SpringBoot整合mybatis-plus及实战演练,赶紧来学!

**My Coding Family** 1万+

Mybatis批处理踩坑,纠正网上的一些错误写法

这篇文章会一步一步带你从一个新手的角度慢慢揭开批处理的神秘面纱,对于初次写Mybatis批处理的同学可能会有很大的帮助,建议收藏点赞~

Linn的博客 3132

WordPress主题开发实战:从零开始手把手教你创建自定义主题(含常用函数大全)

本文是一份WordPress主题开发实战指南,从零开始手把手教你创建自定义主题。内容涵盖主题核心文件结构、模板层级与循环机制、函数与钩子的运用,并附有详细的常用函数大全,帮助开发者彻底掌握主题开发的核心技能,实现从使用者到创造者的转变。

weixin_27943395的博客 256

自动换挡频率计的设计精髓:如何用数字电路优雅地解决量程切换难题

本文深入解析了自动换挡频率计的设计精髓,重点探讨如何利用数字电路优雅解决量程切换难题。通过74系列通用数字集成电路构建智能化的自动量程切换系统,详细介绍了状态检测、决策逻辑和档位执行等核心模块的设计方法,并对比了不同实现方案的优劣,为电子测量领域的工程师提供了实用的硬件设计参考。

weixin_27869497的博客 407

MyBATIS原理第三篇: SqlSession下的四大对象之一——执行器(executor)

首先我先解释一下标题 四大对象是指:executor, statementHandler,parameterHandler,resultHandler对象。(为了方便下面的文章说道四大对象就专指它们) 它们都是sqlSession的底层类实现,也是插件能够拦截的四大对象。所以这里已经触及了MyBATIS的底层,动态代理,反射随时可以看到,如果没有第一篇作为基础,你将十分难以理解它。了解他们的协作

ykzhen2015的专栏 1万+

IEEE论文接收后,收到Proof邮件别慌!手把手教你48小时内搞定校样(附详细截图)

本文详细解析了IEEE论文接收后Proof校样的全流程,从邮件关键信息解码到精准修改标注,提供48小时内高效完成校样的实战指南。涵盖登录技巧、文件验证、修改标注黄金法则及九宫格检查清单,帮助作者避免常见错误,确保论文顺利发表。

weixin_30652491的博客 563

MyBatis-Plus配置项

来看下MyBatis-Plus可以支持哪些配置项(可配置的属性) #################### mybatis-plus配置 ################### mybatis-plus: #外部化xml配置 #config-location: classpath:mybatis-config.xml #指定外部化 MyBatis Properties 配置,通过该配置可以抽离配置,实现不同环境的配置部署 #configuration-properties: clas

Be_insighted的博客 2141

7.5华为OD机试真题 新系统 - 省超足球比赛获胜队伍计算 (Java/Py/C/C++/Js/Go)

7.5华为OD机试真题 新系统 - 省超足球比赛获胜队伍计算 (Java/Py/C/C++/Js/Go)

算法大师! 820

FT2004(D2000)开发实战之网口stmmac报错调试(Failed to reset the dma)

网口stmmac报错调试(Failed to reset the dma)

嵌入式Linux 3584

浅谈mybatis-Cache

mybatis-cache简介源码解读缓存使用总结&反思 每次在编写文章之前自己都喜欢先来个感想,今天的话题是多读英文文档,好处多多!什么情况下要考虑缓存问题呢?一般微服务架构设计时,分布式应用可能导致脏数据,特别是在秒杀情况下需要特别注意(可以接入外部二级缓存) 简介 文档中已经很明显说明了什么cashe,什么是一级缓存和二次缓存。个人就总结为:缓存即相同查询时,在没有发生更新、提交、回滚和关闭时,多次查询不会从数据库中返回,直接从Cashe的缓存实现类中返回。一级缓存居于sqlsesson缓存,

soft_z1302的博客 2516

2025华为OD 面试手撕代码真题【字符串至多删除一个字符,是否能构成回文串】

2025华为OD 面试手撕代码真题【字符串至多删除一个字符,是否能构成回文串】

MISAYAONE的博客 1705

Spring Boot整合MyBatis

在开发中,通常会涉及到对数据库的数据进行操作,Spring Boot在简化项目开发以及实现自动化配置的基础上,对关系型数据库和非关系型数据库的访问操作都提供了非常好的整合支持。Spring Boot默认采用整合SpringData的方式统一处理数据访问层,通过添加大量自动配置,引入各种数据访问模板xxxTemplate以及统一的Repository接口,从而达到简化数据访问层的操作。Spring Boot提供的常见数据库依赖启动器名称对应数据库。

梁辰兴的博客 1万+

倍福EL5101模块连接编码器

1、 EL5101模块简介:EL5101为单通道增量型编码器计数模块,一共有EL5101-0000、EL5101-0010、EL5101-0011、EL5101-0090(尚未供货)四种型号,其中EL5101-0000比较常用,本例使用EL5101-0000连接增量型编码器 2、 硬件外观和接线 在这里插入图片描述 3、 指示灯说明 4、和编码器连接的案例 ......

weixin_41883890的博客 6501

AI算力网络与通信领域QoS保障的测试方法

在当今数字化时代,AI技术蓬勃发展,AI算力网络应运而生。它将分布在不同地理位置的算力资源进行整合,以高效地支持各种AI应用,如深度学习训练、智能图像识别等。而通信领域则是信息传输的基石,确保数据能够准确、快速地在不同节点之间传递。QoS保障在通信领域至关重要,它可以确保不同类型的业务(如语音通话、视频会议、在线游戏等)获得与其需求相匹配的服务质量。在AI算力网络中,QoS保障同样不可或缺,因为AI任务对网络的带宽、延迟、可靠性等指标有严格要求。

AI算力网络与通信的博客 526

Spring Boot整合MyBatis实现简单的CRUD

这篇文章主要针对java初学者,详细介绍如何创建一个基本的springboot项目来对数据库进行crud操作。

沐雨橙风ιε的博客 4487

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

Spring Boot 整合 MyBatis 全攻略

<groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>x.x.x</version>

caisang0110的博客 2756

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

【MyBatis】MyBatis与Spring和Spring Boot整合原理

讲解Spring Boot如何整合MyBatis,并分析其原理。

小七的博客 1620

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

图文详解Spring Boot整合MyBatis(附源码)

本文详细介绍了SpringBoot整合MyBatis的开发流程。首先通过SQL脚本创建数据库mybatisdb和员工表,并初始化测试数据。随后创建SpringBoot项目,配置JDK、Maven等开发环境,添加MySQL驱动、Druid连接池和MyBatis依赖。重点讲解了项目结构规范,包括Java代码包划分和resources目录下mapper映射文件的存放规则。最后配置项目启动类,使用@MapperScan注解扫描mapper接口。教程提供了完整的图文操作指引。

谷哥的小弟 1526

spring boot整合logback和mybatis详解

wongHLOGPATH/{LOG_PATH}/LOGP​ATH/{APPDIR}/wongH_log_error.logLOGPATH/{LOG_PATH}/LOGP​ATH/{APPDIR}/error/wongH_log-error-%d{yyyy-MM-dd}.%i.log10MBtrue%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level — [%thread] %logger Line:%-3L - %msg%nutf-8errorACCEPTDENYLOGPATH/{LOG

2301_82242251的博客 1125

Spring Boot 整合 MyBatis 教程:从入门到实践

本文详细介绍了 Spring Boot 整合 MyBatis 的步骤,包括环境准备、数据库配置、实体类创建、Mapper 接口和 XML 文件编写、Service 层和 Controller 层的实现以及最后的测试。通过这种整合,开发者可以利用 Spring Boot 和 MyBatis 的优势,快速构建出功能强大的数据库驱动的 Web 应用程序。希望本文对读者在学习和实践 Spring Boot 与 MyBatis 整合方面有所帮助,读者可以进一步探索这两个框架的更多高级特性,以满足更复杂的业务需求。

a199466的博客 1000

Spring Boot 整合 MyBatis 全流程指南

在实际开发中,配置文件的使用至关重要。本文将通过一个案例详细讲解 Spring Boot 整合 MyBatis 的过程,包括整合步骤、代码编写以及配置文件的使用,同时展示 Spring Boot 起步依赖和自动配置带来的便捷之处。

m0_57836225的博客 1274

Spring Boot整合MyBatis+MySQL教程(附详细代码)

本文详细介绍了SpringBoot整合MyBatis和MySQL的完整流程。首先通过IDEA创建SpringBoot项目,配置Maven依赖,构建标准分层架构。然后整合MyBatis,包括编写Mapper接口和XML映射文件,配置数据源信息。最后创建数据库表结构并进行测试验证,提供了完整的application.yml配置和源码地址。整个过程涵盖了项目搭建、框架整合、数据库操作等关键环节,为开发者提供了快速构建SpringBoot+MyBatis+MySQL项目的实用指南

qq_47980550的博客 2400

Spring Boot整合tk-mybatis、PageHelper

本文介绍了tk-mybatis这一曾经流行的MyBatis增强框架的使用方法,尽管它已被MyBatis-Plus取代,但仍值得了解。文章详细展示了如何从零开始整合tk-mybatis:从数据库准备(创建歌曲表并插入测试数据)、创建Spring Boot项目、添加依赖(包括tk-mybatis和分页插件PageHelper),到配置数据源和MyBatis。重点讲解了实体类创建、Mapper接口定义(继承tk.mybatis.mapper.common.Mapper)以及核心API的使用,包括增删改查操作和基于

沐雨橙风ιε的博客 3560
上一篇: Spring Boot入门系列之:二、Spring Boot整合JPA
下一篇: Spring Boot入门系列之:五、Spring Boot整合mail
exklin
博客等级 码龄9年 35粉丝 68原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值