Spring Boot整合MyBatis连接数据库

Spring Boot整合MyBatis全攻略:原理剖析与最佳实践 传统Spring项目中整合MyBatis需要配置大量XML和Bean,而Spring Boot通过自动配置和starter机制,实现了"开箱即用"的MyBatis集成体验。零XML配置:基于注解和Java Config的配置方式自动配置:自动发现DataSource、SqlSessionFactory等简化分页:内置分页插件支持强大扩展:支持通用Mapper、MyBatis-Plus等增强工具Spring Boot与MyBatis的整合为Java开发者提供了高效、灵活的数据访问解决方案。 阅读详情
AI摘要

本文详细介绍了如何在SpringBoot项目中整合MyBatis框架,包括环境搭建、依赖引入、数据源配置、实体类创建、DAO层实现、Service层与Controller层设计,以及使用MyBatis Generator自动生成代码的过程。

GitHub:SpringBootDemo
Gitee:SpringBootDemo
微信公众号:在这里插入图片描述

0. 开发环境

  • IDE:IntelliJ IDEA 2017.1 x64
  • jdk:1.8.0_91
  • Spring Boot:2.1.1.RELEASE
  • Maven:3.3.9
  • MySQL:5.7.13

1. 引入依赖

<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>8.0.15</version>
	<scope>runtime</scope>
</dependency>

这里,如果使用的 MySQL 是 8.X版本的话,mysql-connector-java 版本必须是 8.0以上,否则会报错:

java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'.

2. 引入数据源

这里根据个人习惯使用 properties 或 yml 文件配置,本项目使用的是更为简洁的 yml 配置文件。
删除原来的 application.properties ,新建 application.yml。

application.yml 增加如下配置信息

spring:
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/test?serverTimezone=GMT%2B8
    username: root
    password: root
    driver-class-name: com.mysql.cj.jdbc.Driver

这里,如果使用的 mysql-connector-java 是5.X版本的话,driver-class-name 可以直接省略使用默认,或者配置为 com.mysql.jdbc.Driver

到这里,Spring Boot就可以访问数据库了,我们来做下测试。


3. 测试

3.1 新建数据库表

CREATE SCHEMA `test` ;

CREATE TABLE `test`.`test` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`id`));

INSERT INTO `test`.`test` (`name`) VALUES ('张三');
INSERT INTO `test`.`test` (`name`) VALUES ('李四');
INSERT INTO `test`.`test` (`name`) VALUES ('王五');
INSERT INTO `test`.`test` (`name`) VALUES ('周六');

3.2 创建实体

package cn.wbnull.springbootdemo.model;

public class TestModel {

    private int id;
    private String name;

    public int getId() {
        return id;
    }

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

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

3.3 DAO层

package cn.wbnull.springbootdemo.dao;

import cn.wbnull.springbootdemo.model.TestModel;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TestMapper {

    @Select("select id,name from test")
    List<TestModel> select();

    @Insert("insert into test(name) values(#{name})")
    int insert(@Param("name") String name);
}

3.4 Service层

package cn.wbnull.springbootdemo.service;

import cn.wbnull.springbootdemo.dao.TestMapper;
import cn.wbnull.springbootdemo.model.TestModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MySQLTestService {

    @Autowired
    private TestMapper testMapper;  //这里会有报错,不用管

    public List<TestModel> select() {
        return testMapper.select();
    }

    public int insert(String name) {
        return testMapper.insert(name);
    }
}

这里使用 @Autowired 自动装配TestMapper时会有报错,原因是TestMapper使用了@Mapper注解,idea不能把@Mapper注解的TestMapper识别为Bean,但实际运行时@Mapper会被Spring识别为Bean,自动装配不会出错。所以这里的报错可以不用在意。
但如果看着代码中有报错很不顺眼,可以在TestMapper类增加@Repository注解,标注该类为DAO组件。


3.5 Controller层

package cn.wbnull.springbootdemo.controller;

import cn.wbnull.springbootdemo.model.TestModel;
import cn.wbnull.springbootdemo.service.MySQLTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Scope("prototype")
@RequestMapping("/mysql/test")
public class MySQLTestController {

    @Autowired
    private MySQLTestService mySQLTestService;

    @PostMapping(value = "/select")
    public List<TestModel> select() throws Exception {
        return mySQLTestService.select();
    }

    @PostMapping(value = "/insert")
    public int insert(@RequestParam(value = "name") String name) throws Exception {
        return mySQLTestService.insert(name);
    }
}

3.6 测试

使用Postman进行测试,输出结果如下

3.6.1 select

在这里插入图片描述

3.6.2 insert

在这里插入图片描述
Postman接收到输出为1,表示成功,我们去查下数据库
在这里插入图片描述
数据成功插入。


4. MyBatis映射文件

以上,我们访问数据库时,SQL语句还是写死在代码里面,处理起来并没有很方便。通常,我们把SQL语句与代码分离,使用MyBatis映射文件方式来访问数据库。

4.1 MyBatis配置

我们在resources文件夹下新建mapper文件夹,用于存放MyBatis映射文件
在这里插入图片描述
application.yml 增加MyBatis配置信息

mybatis:
  mapper-locations: classpath:mapper/*.xml  #对应mapper映射xml文件所在路径
  type-aliases-package: cn.wbnull.springbootdemo.model  #对应实体类路径

完整配置如下,注意spring与mybatis都是根节点

spring:
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/test?serverTimezone=GMT%2B8
    username: root
    password: root
    driver-class-name: com.mysql.cj.jdbc.Driver
#
mybatis:
  mapper-locations: classpath:mapper/*.xml  #对应mapper映射xml文件所在路径
  type-aliases-package: cn.wbnull.springbootdemo.model  #对应实体类路径

4.2 DAO层

我们创建一个新的DAO类

package cn.wbnull.springbootdemo.dao;

import cn.wbnull.springbootdemo.model.TestModel;

import java.util.List;

public interface TestMapperV2 {

    List<TestModel> select();

    int insert(TestModel testModel);
}

4.3 创建MyBatis映射文件

resources/mapper下新建映射文件 TestMapper.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="cn.wbnull.springbootdemo.dao.TestMapperV2">
    <resultMap id="BaseResultMap" type="cn.wbnull.springbootdemo.model.TestModel">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="name" property="name" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">
        id, name
    </sql>
    <select id="select" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from test
    </select>
    <insert id="insert" parameterType="cn.wbnull.springbootdemo.model.TestModel">
        insert into test (id, name
        )
        values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}
        )
    </insert>
</mapper>

这里着重注意这几点

1、<mapper namespace=“cn.wbnull.springbootdemo.dao.TestMapperV2”> namespace 一定要对应自己dao包所在的包路径,对应我们需要匹配的dao层类

2、<resultMap id=“BaseResultMap” type=“cn.wbnull.springbootdemo.model.TestModel”> type 一定要对应我们需要匹配的实体类

3、 <id column=“id” property=“id” jdbcType=“INTEGER”/>

​ <result column=“name” property=“name” jdbcType=“VARCHAR”/>

对应数据库表的字段

4、<select id=“select” resultMap=“BaseResultMap”>

​ select <include refid=“Base_Column_List”/> from test

​ </select>

<select> 表示这是一条查询语句, id=“select” 一定要与dao层需要匹配的方法名一致,resultMap 表示对应的返回值类型

5、<insert id=“insert” parameterType=“cn.wbnull.springbootdemo.model.TestModel”> parameterType表示对应的输入参数类型

4.4 Service层

创建一个新的Service类

package cn.wbnull.springbootdemo.service;

import cn.wbnull.springbootdemo.dao.TestMapperV2;
import cn.wbnull.springbootdemo.model.TestModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MySQLTestServiceV2 {

    @Autowired
    private TestMapperV2 testMapperV2;  //这里会有报错,不用管

    public List<TestModel> select() {
        return testMapperV2.select();
    }

    public int insert(int id, String name) {
        TestModel testModel = new TestModel();
        testModel.setId(id);
        testModel.setName(name);

        return testMapperV2.insert(testModel);
    }
}

4.5 Controller层

创建一个新的Controller类

package cn.wbnull.springbootdemo.controller;

import cn.wbnull.springbootdemo.model.TestModel;
import cn.wbnull.springbootdemo.service.MySQLTestServiceV2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Scope("prototype")
@RequestMapping("/mysql/test")
public class MySQLTestControllerV2 {

    @Autowired
    private MySQLTestServiceV2 mySQLTestServiceV2;

    @PostMapping(value = "/selectV2")
    public List<TestModel> select() throws Exception {
        return mySQLTestServiceV2.select();
    }

    @PostMapping(value = "/insertV2")
    public int insert(@RequestParam(value = "id") int id,
                      @RequestParam(value = "name") String name) throws Exception {
        return mySQLTestServiceV2.insert(id, name);
    }
}

4.6 项目启动类

增加@MapperScan(“cn.wbnull.springbootdemo.dao”),对应DAO层的包名

package cn.wbnull.springbootdemo;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan("cn.wbnull.springbootdemo.dao")
public class SpringBootDemoApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringBootDemoApplication.class, args);
	}
}

4.7 测试

4.7.1 select

在这里插入图片描述

4.7.2 insert

在这里插入图片描述
Postman接收到输出为1,表示成功,我们去查下数据库
在这里插入图片描述
数据成功插入


截至这里,Spring Boot已成功整合MyBatis并连接上了数据库,且测试正常。

但我们实际开发过程中,如果存在大量数据库表,那我们就需要创建大量的实体类、DAO层、映射文件,工作量较大。我们使用mybatis generator来自动生成代码。

5. Generator

5.1 新建数据库表

我们先新建一个数据库表,便于一会自动生成代码使用

CREATE TABLE `test`.`testv2` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `username` VARCHAR(45) NOT NULL,
  `password` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`id`));

5.2 Generator配置文件

在resources文件夹下新建generator文件夹,新建generatorConfig.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
        PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
        "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
    <!--数据库驱动,选择本地硬盘上的数据库驱动包,建议与pom.xml引入的jar包版本相同-->
    <classPathEntry
            location="D:\Program Files\Maven\repository\mysql\mysql-connector-java\8.0.15\mysql-connector-java-8.0.15.jar"/>
    <context id="DB2Tables" targetRuntime="MyBatis3">
        <commentGenerator>
            <property name="suppressDate" value="true"/>
            <!--是否去除自动生成的注释,true:是  false:否-->
            <property name="suppressAllComments" value="true"/>
        </commentGenerator>

        <!--数据库驱动类、链接url、用户名、密码,与application.yml配置相同即可-->
        <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
                        connectionURL="jdbc:mysql://127.0.0.1:3306/test?serverTimezone=GMT%2B8"
                        userId="root"
                        password="root">
        </jdbcConnection>

        <javaTypeResolver>
            <property name="forceBigDecimals" value="false"/>
        </javaTypeResolver>

        <!--生成实体类的包名和位置-->
        <javaModelGenerator targetPackage="cn.wbnull.springbootdemo.model"
                            targetProject="src/main/java">
            <property name="enableSubPackages" value="true"/>
            <property name="trimStrings" value="true"/>
        </javaModelGenerator>

        <!--生成映射文件的包名和位置-->
        <sqlMapGenerator targetPackage="mapper"
                         targetProject="src/main/resources">
            <property name="enableSubPackages" value="true"/>
        </sqlMapGenerator>

        <!--生成DAO的包名和位置-->
        <javaClientGenerator type="XMLMAPPER"
                             targetPackage="cn.wbnull.springbootdemo.dao"
                             targetProject="src/main/java">
            <property name="enableSubPackages" value="true"/>
        </javaClientGenerator>

        <!--需要自动生成代码的数据库表
         tableName表示数据库中的表名或视图名 domainObjectName表示实体类名-->
        <table tableName="testv2" domainObjectName="TestV2"
               enableCountByExample="false" enableUpdateByExample="false"
               enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
    </context>
</generatorConfiguration>

5.3 引入依赖

<plugin>
	<groupId>org.mybatis.generator</groupId>
	<artifactId>mybatis-generator-maven-plugin</artifactId>
	<version>1.3.2</version>
	<configuration>
		<configurationFile>${basedir}/src/main/resources/generator/generatorConfig.xml</configurationFile>
		<overwrite>true</overwrite>
		<verbose>true</verbose>
	</configuration>
</plugin>

5.4 Generator配置

1、Run --> Edit Configurations…
在这里插入图片描述
2、增加Maven配置
在这里插入图片描述
3、增加Generator配置 (mybatis-generator:generate -e),OK
在这里插入图片描述
4、运行
在这里插入图片描述
生成代码如下。这里我们运行成功后,同一个表,不要运行多次,否则mapper映射文件中会生成多次的代码。
在这里插入图片描述

package cn.wbnull.springbootdemo.model;

public class TestV2 {
    private Integer id;

    private String username;

    private String password;

    public Integer getId() {
        return id;
    }

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

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username == null ? null : username.trim();
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password == null ? null : password.trim();
    }
}
package cn.wbnull.springbootdemo.dao;

import cn.wbnull.springbootdemo.model.TestV2;

public interface TestV2Mapper {
    int insert(TestV2 record);

    int insertSelective(TestV2 record);
}
<?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="cn.wbnull.springbootdemo.dao.TestV2Mapper" >
  <resultMap id="BaseResultMap" type="cn.wbnull.springbootdemo.model.TestV2" >
    <result column="id" property="id" jdbcType="INTEGER" />
    <result column="username" property="username" jdbcType="VARCHAR" />
    <result column="password" property="password" jdbcType="VARCHAR" />
  </resultMap>
  <insert id="insert" parameterType="cn.wbnull.springbootdemo.model.TestV2" >
    insert into testv2 (id, username, password
      )
    values (#{id,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="cn.wbnull.springbootdemo.model.TestV2" >
    insert into testv2
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="username != null" >
        username,
      </if>
      <if test="password != null" >
        password,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="username != null" >
        #{username,jdbcType=VARCHAR},
      </if>
      <if test="password != null" >
        #{password,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
</mapper>

5.5 测试

5.5.1 Service层

package cn.wbnull.springbootdemo.service;

import cn.wbnull.springbootdemo.dao.TestV2Mapper;
import cn.wbnull.springbootdemo.model.TestV2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MySQLTestV2Service {

    @Autowired
    private TestV2Mapper testV2Mapper;  //这里会有报错,不用管

    public int insert(int id, String username, String password) {
        TestV2 testV2 = new TestV2();
        testV2.setId(id);
        testV2.setUsername(username);
        testV2.setPassword(password);

        return testV2Mapper.insert(testV2);
    }
}

5.5.1 Controller层

package cn.wbnull.springbootdemo.controller;

import cn.wbnull.springbootdemo.service.MySQLTestV2Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Scope("prototype")
@RequestMapping("/mysql/testv2")
public class MySQLTestV2Controller {

    @Autowired
    private MySQLTestV2Service mySQLTestV2Service;

    @PostMapping(value = "/insert")
    public int insert(@RequestParam(value = "id") int id,
                      @RequestParam(value = "username") String username,
                      @RequestParam(value = "password") String password
    ) throws Exception {
        return mySQLTestV2Service.insert(id, username, password);
    }
}

5.5.2 insert

在这里插入图片描述
Postman接收到输出为1,表示成功,我们去查下数据库
在这里插入图片描述
数据成功插入


这样,对于大量的数据库表,我们就可以使用Generator来生成基本的代码,然后自己再添加其他所需要的代码即可。


微信:https://mp.weixin.qq.com/s/TVtmbSBrctv9R9EucIggYg
微博:https://weibo.com/ttarticle/p/show?id=2309404339889012367676
知乎:https://zhuanlan.zhihu.com/p/95635187


Spring Boot 通过mybatis接入MySql数据库 Spring Boot、Mybatis 阅读详情

相关推荐

Spring Boot中集成MyBatis操作数据库详细教程

在Java开发中,MyBatis是一款轻量级且灵活的持久层框架,支持SQL语句和自定义映射,尤其适合需要复杂SQL操作的应用场景。结合Spring Boot,我们可以更加方便地使用MyBatis进行数据操作。本篇文章将手把手地介绍如何在Spring Boot项目中集成MyBatis,并实现基础的增删改查操作。我们会从依赖配置开始,到实体类、Mapper接口、Service和Controller的创建,最终形成一个简洁易用的应用结构。在包中创建。

m0_74825526的博客 1103

SpringBoot整合Mybatis

SpringBoot整合Mybatis

junR_980218的博客 5万+

Spring Boot 项目整合 MyBatis 连接数据库

在我们日常的开发过程中,肯定不可避免的会使用到数据库以及 SQL 语句。比如,刚开始学习 Java 的时候可能会遇到 JDBC,它是连接 Java 和数据库的桥梁,我们可以使用 JDBC 来建立与数据库之间的连接并且执行相应的 SQL 语句。虽然 JDBC 的执行效率很高,但是其开发效率比较低。正是如此,市面上出现了一大批 ORM(对象关系映射)框架,例如 Hibernate,iBATIS 以及本文将要介绍的 MyBatis。 MyBatis 简介 MyBatis 是一款优秀的持久层框架,它支持定制化

m0_67322837的博客 830

SpringBoot结合MyBatis 【超详细】

Spring Boot与MyBatis框架集合实践。内置MyBatis大部分使用技巧,而Spring Boot起到个快速入门的效果。其中MyBatis内容涉及到业务层与数据访问层的传参知识、企业常用的动态SQL拼接、高级映射及延迟加载、以及缓存机制、最后包括PageHelper分页插件

m0_65563175的博客 12万+

Spring Boot 整合 MyBatis 连接 Oracle数据库

1、Spring Boot项目添加MyBatis依赖和Oracle驱动:   &lt;dependency&gt; &lt;groupId&gt;org.mybatis.spring.boot&lt;/groupId&gt; &lt;artifactId&gt;mybatis-spring-boot-starter&lt;/artifactId&gt; &lt;version&gt;1....

javaQQ561487941的博客 1754

IDEA工具springboot项目连接数据库,整合mybatis

1、IDEA连接数据库 1)导入相关依赖 <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.10</version&gt

weixin_45736644的博客 784

Spring Boot 整合 MyBatis 连接数据库详解

MyBatis 是一个优秀的持久层框架,支持定制化 SQL、存储过程以及高级映射。下面详细介绍如何在 Spring Boot 项目中整合 MyBatis 并连接数据库。

weixin_52578852的博客 2716

GBase 8a 与 Spring Boot + MyBatis 整合实战:从环境搭建到CRUD操作

通过以上步骤,我们实现了GBase数据库与Spring Boot、MyBatis的深度整合,构建了完整的CRUD操作体系。这种组合既能发挥GBase在海量数据处理上的优势,又能利用Spring Boot的快速开发特性和MyBatis的灵活SQL控制能力,非常适合企业级数据管理系统开发。连接池优化(HikariCP参数调整)SQL性能监控(MyBatis插件如PageHelper)分布式事务支持(Seata框架集成)通过合理配置和扩展,该架构可以轻松应对高并发、大数据量的复杂业务场景。

weixin_41544125的博客 1852

mybatis连接mysql步骤_Spring Boot整合MyBatis连接Oracle数据库的步骤全纪录

Spring Boot整合MyBatis连接Oracle数据库的步骤全纪录发布时间:2020-08-19 15:39:16来源:脚本之家阅读:112作者:♚帅前言本文主要分享了Spring Boot整合MyBatis连接Oracle数据库的相关内容,下面话不多说了,直接来详细的步骤吧。步骤如下:1、Spring Boot项目添加MyBatis依赖和Oracle驱动:org.mybatis.spri...

weixin_39620629的博客 336

【WILEY】从Revision到Online:逐层拆解投稿状态更新与关键文件提交实战

本文详细解析了学术论文从返修到在线发表的全过程,重点拆解了投稿系统状态更新背后的含义与应对策略。文章提供了返修稿与回复信的准备技巧、关键补充文件(如图文摘要)的提交要点,并分享了校对校样与处理出版协议的实战经验,帮助作者高效、专业地完成发表流程。

weixin_29209805的博客 713

实验六 存储器实验

只读存储器(ROM)是一种在正常工作时其存储的数据固定不变,其中的数据只能读出,不能写入,即使断电也能够保留数据,要想在只读存储器中存入或改变数据,必须具备特定的条件。当地址为00000101时,会分别在数据位宽为8,16,32的只读寄存器中找到地址为00000101所对应的十进制地址位置,也就是地址为5的数据,并将其分别以8位,16位,32位输出。因此,输出保持为0。因此,当异步清零信号为1时,无论其他输入信号是什么,触发器的输出都会被强制清零,输出为0。1)寄存器输入0011,使能端1,异步清零0。

wenmou1111的博客 3003

mybatis连接mysql数据库步骤_Spring Boot整合MyBatis连接Oracle数据库的步骤全纪录

前言本文主要分享了Spring Boot整合MyBatis连接Oracle数据库的相关内容,下面话不多说了,直接来详细的步骤吧。步骤如下:1、Spring Boot项目添加MyBatis依赖和Oracle驱动:org.mybatis.spring.bootmybatis-spring-boot-starter1.3.2com.oracleojdbc611.2.0.1.02、配置applicatio...

weixin_39607710的博客 385

大数据国赛第2套任务C-子任务一特征工程

根据**Hudi**的dwd_ds_hudi库中相关表或MySQL中shtd_store中相关表(order_detail、sku_info),计算出与用户id为6708的用户所购买相同商品种类最多的前10位用户(只考虑他俩购买过多少种相同的商品,不考虑相同的商品买了多少次),将10位用户id进行输出,若与多个用户购买的商品种类相同,则输出结果按照用户id升序排序,输出格式如下,将结果截图粘贴至客户端桌面【Release任务C提交结果.docx】中对应的任务序号下;

weixin_44117248的博客 903

spring boot的使用入门-使用Druid连接池整合Mybatis-Plus连接Mysql数据库

使用Druid连接池整合Mybatis-Plus1、添加依赖2、修改application.properties配置文件3、Druid 部分代码1 DruidConfiguration 配置类4、Mybatis-Plus部分5、其他部分代码ModelMapper 和 Mapper.xmlService 和 ServiceImplController6、工程结构图7、测试发送请求druid管理界面8...

only3c的博客 6795

从踩坑到填平:我在RHEL7上给Tesla A100装驱动的完整记录(含Fabric Manager配置)

本文详细记录了在RHEL7系统上为Tesla A100安装Nvidia驱动的完整过程,包括Fabric Manager配置的关键步骤。通过分析A100架构的特殊性,提供了从驱动安装到服务配置的详细指南,并分享了常见问题的排查方法和性能调优技巧,帮助用户高效部署高性能GPU计算环境。

weixin_29291863的博客 283

AI人工智能全模态大模型架构:推动智能交通发展的架构设计

本文旨在阐述全模态大模型在智能交通领域的架构设计原理和应用方法。我们将探讨如何利用多模态AI技术解决交通流量预测、事故预警、路线优化等关键问题。文章将从基础概念入手,逐步深入技术细节,最后探讨实际应用和未来发展方向。全模态大模型:能够处理和理解多种数据模态(如图像、文本、语音等)的大型AI模型智能交通系统(ITS):利用先进技术优化交通流量和安全性的综合系统多模态融合:将不同数据源的信息整合处理的技术核心概念回顾全模态大模型是能够处理多种数据类型的强大AI系统。

AGI×大数据,开启智能时代的认知跃迁;解码AGI,赋能数据驱动的智能革命。 834

Spring Boot整合MyBatis-Flex实现数据库连接信息加密配置实战

在Java企业级应用开发中,数据库连接配置的安全性至关重要。通过对称加密算法对敏感信息进行保护,能够有效防止配置泄露导致的数据安全风险。其技术原理是在应用启动阶段,通过自定义环境处理器拦截加密属性,利用密钥进行实时解密,确保数据源获取到的是明文信息。这一实践不仅提升了系统的安全基线,还实现了对业务代码的透明化处理。在Spring Boot生态中,结合MyBatis-Flex框架,可以优雅地实现配置加解密流程。本文聚焦于利用Jasypt库和EnvironmentPostProcessor扩展点,详解如何为My

weixin_34327223的博客 373

安卓开发者必看:Win11最新Fastboot驱动安装避坑指南(含Android Bootloader Interface选择技巧)

本文为安卓开发者提供了Windows 11系统下Fastboot驱动安装的详细指南,特别针对Android Bootloader Interface选择技巧和多设备并发连接时的驱动冲突问题。通过解析Windows 11的特殊驱动验证机制,推荐使用Google官方USB驱动,并提供安装流程、版本选择建议及疑难问题排查方法,帮助开发者高效完成开发环境配置。

sea99的博客 1332

spring boot 整合MyBatis连接数据库

整合MyBatis连接数据库 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <...

qq_44729800的博客 159

从底层结构开始学习FPGA(8)----Block RAM(BRAM,块RAM)

BRAM作为FPGA底层的存储资源,作用很大,比如可以RAM/ROM/FIFO。

孤独的单刀 2万+

Python反爬实战|动态渲染+高可用IP代理集群,稳定爬取京东/淘宝10万+商品数据

做Python电商爬虫的同学,应该都对京东、淘宝的反爬机制深有体会——这两个平台的反爬体系,堪称国内网站的天花板,远比普通资讯、政务网站的反爬严格十倍不止。用requests库请求商品列表,返回的永远是只有骨架的空HTML,商品标题、价格、销量全是前端JS异步加载,抓包分析接口发现参数全是加密的signtoken,解密成本无限高;用selenium开无头浏览器爬取,刚爬3-5页就触发风控,页面直接返回403,IP被封禁,甚至连Cookie都直接失效;

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1585

druid连接池mysql5.7_Spring Boot 使用Druid连接池整合Mybatis-Plus连接Mysql数据库

一、连接池在普通的数据库访问程序中,客户程序得到的连接对象是物理连接,调用连接对象的close()方法将关闭连接,而采用连接池技术,客户程序得到的连接对象是连接池中物理连接的一个句柄,调用连接对象的close()方法,物理连接并没有关闭,数据源的实现只是删除了客户程序中的连接对象和池中的连接对象之间的联系。二、连接池框架比较目前常用的连接池框架主要有c3p0、dbcp、proxool、druid。...

weixin_35572715的博客 1241

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

Spring Boot整合MyBatis Plus连接数据库

在这篇文章中,我们已经可以使用Spring Boot整合MyBatis来连接数据库,但随着使用,我们发现,MyBatis还是稍微有点复杂,那有没有更加简单的方式来操作数据库呢,我们惊奇的发现了MyBatis Plus。

null 2429

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

Spring-Boot整合mybatis(一),使用默认的数据库连接池

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

weixin_34146410的博客 1789
上一篇: 深入理解Spring两大特性:IoC和AOP
下一篇: Spring Boot使用Schedule实现定时任务
程序员null
博客等级 码龄11年 1304粉丝 124原创
评论 6
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值