Springboot——数据访问

超详细讲解SpringBoot——数据访问 前言: 大部分系统都离不开数据访问,数据库包括SQL和NOSQL,SQL是指关系型数据库,常见的有SQL Server,Oracle,MySQL(开源),NOSQL是泛指非关系型数据库,常见的有MongoDB,Redis。 用spring开发时我们常用的ORM框架有JDBC、Mybatis,Hibernate,现在最常用的应该是Mybatis。 在Springboot中对于数据访问层,无论是SQL还是NOSQL,都默认采用整合Spring Data的方式进行统一处理,Springboot会帮我们添加大量自动 阅读详情

一、SQL

1. 数据源的自动配置

数据源重在连接,配置连接属性,而连接池是数据源内实现的,也是为了高效连接而存在

1.1 导入JDBC场景

  • 首先导入JDBC场景
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>

会根据依赖自动导入数据源、jdbc以及事务

  • 导入数据库驱动

选择要导入的数据库驱动,版本统一

直接依赖引入具体版本(maven的就近依赖原则)

<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.26</version>
</dependency>

1.2 分析自动配置

  • DataSourceAutoConfiguration : 数据源的自动配置。

    • 修改数据源相关的配置:spring.datasource
    • 数据库连接池的配置:如果容器中没有数据源,就默认给你放一个。
    • 底层配置好的连接池是:HikariDataSource
  • DataSourceTransactionManagerAutoConfiguration: 事务管理器的自动配置

  • JdbcTemplateAutoConfiguration: JdbcTemplate的自动配置,可以来对数据库进行CRUD

    • 可以修改前缀为spring.jdbc的配置项来修改JdbcTemplate
    • @Bean @Primary JdbcTemplate:Spring容器中有这个JdbcTemplate组件,使用@Autowired
  • JndiDataSourceAutoConfiguration: JNDI的自动配置

  • XADataSourceAutoConfiguration: 分布式事务相关的

1.3 修改配置项

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/fkddatabase
    username: root
    password: 123456
    driver-class-name: com.mysql.cj.jdbc.Driver

1.4 测试

@Slf4j
@SpringBootTest
class BootAdminApplicationTests {
    //因为容器中注入了JdbcTemplate组件,所以可以自动注入
    @Autowired
    JdbcTemplate jdbcTemplate;

    @Test
    void contextLoads() {
        Long aLong = jdbcTemplate.queryForObject("select count(*) from emp", Long.class);
        log.info("总记录数是:{}", aLong);
    }
}

2. 使用Druid数据源

2.1 druid官方github地址

Druid是数据库连接池,它能够提供强大的监控和扩展功能

Druid官方github地址

Spring Boot整合第三方技术的两种方式:

  • 自定义(自定义configuration类,参考配置文档@Bean组件)

  • 找starter场景

2.2 使用官方starter的方式

官方文档 - Druid Spring Boot Starter

  • 引入依赖:

    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>druid-spring-boot-starter</artifactId>
        <version>1.1.17</version>
    </dependency>
    
  • 分析自动配置(DruidDataSourceAutoConfigure):

    • 扩展配置项 spring.datasource.druid
    • 自动配置类DruidDataSourceAutoConfigure
    • DruidSpringAopConfiguration.class, 监控SpringBean的;配置项:spring.datasource.druid.aop-patterns
    • DruidStatViewServletConfiguration.class, 监控页的配置。spring.datasource.druid.stat-view-servlet默认开启
    • DruidWebStatFilterConfiguration.class,web监控配置。spring.datasource.druid.web-stat-filter默认开启
    • DruidFilterConfiguration.class:所有Druid的filter的配置
    private static final String FILTER_STAT_PREFIX = "spring.datasource.druid.filter.stat";
    private static final String FILTER_CONFIG_PREFIX = "spring.datasource.druid.filter.config";
    private static final String FILTER_ENCODING_PREFIX = "spring.datasource.druid.filter.encoding";
    private static final String FILTER_SLF4J_PREFIX = "spring.datasource.druid.filter.slf4j";
    private static final String FILTER_LOG4J_PREFIX = "spring.datasource.druid.filter.log4j";
    private static final String FILTER_LOG4J2_PREFIX = "spring.datasource.druid.filter.log4j2";
    private static final String FILTER_COMMONS_LOG_PREFIX = "spring.datasource.druid.filter.commons-log";
    private static final String FILTER_WALL_PREFIX = "spring.datasource.druid.filter.wall";
    
  • 配置示例:

    spring:
      datasource:
        url: jdbc:mysql://localhost:3306/fkddatabase
        username: root
        password: 123456
        driver-class-name: com.mysql.cj.jdbc.Driver
    
        druid:
          aop-patterns: com.zju.admin.*  #监控SpringBean
          filters: stat,wall     # 底层开启功能,stat(sql监控),wall(防火墙)
    
          stat-view-servlet:   # 配置监控页功能
            enabled: true
            login-username: admin
            login-password: 123456
            resetEnable: false
    
          web-stat-filter:  # 监控web
            enabled: true
            urlPattern: /*
            exclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*'
    
    
          filter:
            stat:    # 对上面filters里面的stat的详细配置
              slow-sql-millis: 1000
              logSlowSql: true
              enabled: true
            wall:
              enabled: true
              config:
                drop-table-allow: false
    
  • 访问监控页首页

    http://localhost:8080/druid

3. 整合MyBatis操作

MyBatis的GitHub仓库

MyBatis官方

starter的命名方式:

  1. SpringBoot官方的Starter:spring-boot-starter-*
  2. 第三方的starter: *-spring-boot-starter
  • 引入依赖:
<dependency>
    <groupId>org.mybatis.spring.boot</groupId>
    <artifactId>mybatis-spring-boot-starter</artifactId>
    <version>2.1.4</version>
</dependency>

3.1 配置模式

  • 全局配置文件MybatisAutoConfiguration,读取配置项绑定类
  • SqlSessionFactory:自动配置好了
  • SqlSession:自动配置了SqlSessionTemplate 组合了SqlSession,真正对数据库CRUD
  • @Import(AutoConfiguredMapperScannerRegistrar.class)
  • Mapper: 只要我们写的操作MyBatis的接口标标注了@Mapper就会被自动扫描进来

实例操作:

1. 配置文件application.yaml:

spring:
  datasource:
    username: root
    password: 123456
    url: jdbc:mysql://localhost:3306/fkddatabase
    driver-class-name: com.mysql.cj.jdbc.Driver

# 配置mybatis规则(代替mabatis-config.xml)
mybatis:
  mapper-locations: classpath:mapper/*.xml  #sql映射文件位置
  configuration:
    map-underscore-to-camel-case: true
  type-aliases-package: com.zju.admin

2. Springboot2不需要mybatis-config文件

3. 创建XXXmapper接口与对应XXXmapper.xml

  • 创建数据表对应的实体类
@ToString
@NoArgsConstructor
@Data
public class Emp {
    private String ename;
    private Double sal;
}
  • Mapper接口
@Mapper
public interface ResultMapper {
    /**
     * 根据姓名查询
     * @param name
     * @return
     */
    public Emp getEmp(@Param("name") String name);
}
  • sql映射文件
<?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="com.zju.admin.mapper.ResultMapper">

    <!--public Emp getEmp(@Param("name") String name);-->
    <select id="getEmp" resultType="emp">
        select * from `result` where ename=#{name};
    </select>
</mapper>

4. Service和Controller层

@Service
public class ResultService {

    @Autowired
    ResultMapper resultMapper;

    public Emp getEmpByName(String name){
        return resultMapper.getEmp(name);
    }
}
@Controller
public class IndexController {
    
    @Autowired
    ResultService resultService;

    @ResponseBody
    @RequestMapping("/emp/{empName}")
    public Emp getByName(@PathVariable("empName") String name){
        Emp emp = resultService.getEmpByName(name);
        return emp;
    }
}

总结:

  • 导入mybatis官方starter
  • 编写mapper接口。标准@Mapper注解
  • 编写sql映射文件并绑定mapper接口
  • 在application.yaml中指定Mapper配置文件的位置,以及指定全局配置文件的信息

3.2 注解模式

1.可以通过Spring Initializr添加MyBatis的Starter

2. 省去XXXmapper.xml,在接口上加注解

@Select("select * from `result` where sal>#{sal}")
public List<Emp> getEmpBySal(@Param("sal") Double sal);

3.3 混合模式

实际开发中简单的CRUD可以写在注解上,复杂的业务用xml文件配置方式

  • ResultMapper
@Mapper
public interface ResultMapper {
    /**
     * 根据姓名查询
     * @param name
     * @return
     */
    public Emp getEmp(@Param("name") String name);

    /**
     * 根据收入查询
     * @param sal
     * @return
     */
    @Select("select * from `result` where sal>#{sal}")
    public List<Emp> getEmpBySal(@Param("sal") Double sal);

    /**
     * 插入员工,json显示自增主键
     * @param emp
     * @return
     */
    @Insert("insert into `result`(`ename`,`sal`) values(#{ename},#{sal}) ")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    public void insertEmp(Emp emp);
}
  • ResultMapper.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="com.zju.admin.mapper.ResultMapper">

    <!--public Emp getEmp(@Param("name") String name);-->
    <select id="getEmp" resultType="emp">
        select * from `result` where ename=#{name}
    </select>
    
</mapper>

3.4 最佳实战

  • 引入mybatis-starter
  • 配置application.yaml中,指定mapper-location位置即可
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/fkddatabase
    username: root
    password: 123456
# 配置mybatis规则
mybatis:
  mapper-locations: classpath:mybatis/mapper/*.xml  #sql映射文件位置
  configuration:
    map-underscore-to-camel-case: true
  type-aliases-package: com.zju.admin
  • 编写Mapper接口并标注@Mapper注解

    • 简单方法直接注解方式

    • 复杂方法编写mapper.xml进行绑定映射

  • @MapperScan(“com.zju.admin.mapper”) 简化,其他的接口就可以不用标注@Mapper注解

@MapperScan("com.zju.admin.mapper")
@SpringBootApplication
public class MainApplication {

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

4. 整合MyBatis-Plus完成CRUD

MyBatis-Plus(简称 MP)是一个 MyBatis的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生

4.1 整合MyBatis-Plus

1. 引入依赖

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.5.1</version>
</dependency>

什么都配置好了,注意默认规则:

  • MybatisPlusAutoConfiguration配置类,MybatisPlusProperties配置项绑定
    • mybatis-plus:xxx就是对mabtis-plus的定制
  • SqlSessionFactory自动配置好,底层是容器中默认的数据源。
  • mapperLocations自动配置好的,有默认值classpath*:/mapper/**/*.xml,这表示任意包的类路径下的所有mapper文件夹下任意路径下的所有xml都是sql映射文件。 建议以后sql映射文件放在 mapper下。
  • 容器中也自动配置好了SqlSessionTemplate。
  • @Mapper 标注的接口也会被自动扫描,建议直接 @MapperScan("com.zju.admin.mapper")批量扫描

2. 配置数据源

  • 在 application.yml 配置文件中添加mysql 数据库的相关配置
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/fkddatabase
    username: root
    password: 123456
  • 在 Spring Boot 启动类中添加 @MapperScan 注解,扫描 Mapper 文件夹:
@MapperScan("com.zju.admin.mapper")
@SpringBootApplication
public class BootAdminApplication {

    public static void main(String[] args) {
        SpringApplication.run(BootAdminApplication.class, args);
    }
}
  • 编写对应POJO
    • Mybatis-plus通过数据库pojo名小写得到数据库表名,从而建立对应关系(User类——user表)
    • 可通过@TableName指定
@AllArgsConstructor
@NoArgsConstructor
@Data
@TableName("tb_user")
public class User {
    //两个临时属性,不对应表中的内容
    @TableField(exist = false)
    private String userName;
    @TableField(exist = false)
    private String password;

    private Long id;
    private String name;
    private Integer age;
    private String email;
}
  • 查询的字段名要与属性名对应
    • 通过查询起别名方式
    • 通过resultMap建立自定义映射关系

3. 编写业务接口

  • UserMapper
/**
 * 只需要我们的Mapper继承MyBatisPlus的BaseMapper就可以拥有CRUD能力,减轻开发工作
 */
public interface UserMapper extends BaseMapper<User> {
}

当复杂业务时考虑在resources/mapper下编写业务对应的sql映射xml文件

使用MyBatis Plus提供的IService,ServiceImpl,减轻Service层开发工作:

  • UserService
public interface UserService extends IService<User> {
}
  • UserServiceImpl
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService{
}

4.2 CRUD

1. 添加分页插件

@Configuration
public class MybatisPlusConfig {

    /**
     * 新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题(该属性会在旧插件移除后一同移除)
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2));
        return interceptor;
    }
}

2. 分页数据展示即删除用户

  • 控制层
@GetMapping("/dynamic_table")
public String dynamic_table(Model model, @RequestParam(value = "pn", defaultValue = "1") Long pn){

    //分页查询数据
    Page<User> userPage = new Page<>(pn, 2);

    //分页查询结果
    Page<User> page = userService.page(userPage, null);
    model.addAttribute("page",page);

    return "table/dynamic_table";
}

@GetMapping("/user/delete/{id}")
public String deleteUser(@PathVariable("id") Long id,
                         @RequestParam(value = "pn", defaultValue = "1") Long pn,
                         RedirectAttributes redirectAttributes){
    userService.removeById(id);
    //重定向携带参数
    redirectAttributes.addAttribute("pn", pn);
    return "redirect:/dynamic_table";
}
  • 页面渲染
<div class="adv-table">
    <table class="display table table-bordered" id="hidden-table-info">
        <thead>
            <tr>
                <th>序号</th>
                <th>id</th>
                <th>name</th>
                <th>age</th>
                <th>email</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            <tr class="gradeX" th:each="user,status: ${page.records}">
                <td th:text="${status.count}"></td>
                <td th:text="${user.id}"></td>
                <td>[[${user.name}]]</td>
                <td>[[${user.age}]]</td>
                <td>[[${user.email}]]</td>
                <td><a th:href="@{/user/delete/{id}(id=${user.id},pn=${page.current})}" class="btn btn-danger" type="button">删除</a></td>
            </tr>
        </tbody>
    </table>

    <div class="row-fluid">
        <div class="span6">
            <div class="dataTables_info" id="dynamic-table_info">当前 [[${page.current}]] 页
                总计 [[${page.pages}]] 页 共 [[${page.total}]] 条记录
            </div>
        </div>
        <div class="span6">
            <div class="dataTables_paginate paging_bootstrap pagination">
                <ul>
                    <li class="prev disabled"><a href="#">← Previous</a></li>
                    <li th:class="${num == page.current?'active':''}" th:each="num:${#numbers.sequence(1,page.pages)}">
                        <a th:href="@{/dynamic_table(pn=${num})}">[[${num}]]</a>
                    </li>

                    <li class="next"><a href="#">Next → </a></li>
                </ul>
            </div>
        </div>
    </div>
</div>

二、NoSQL

1. Redis自动配置

添加依赖:

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

<!--导入jedis-->
<dependency>
    <groupId>redis.clients</groupId>
    <artifactId>jedis</artifactId>
</dependency>
  • spring-boot-autoconfigure—data—redis—RedisAutoConfiguration自动配置类,RedisProperties 属性类 --> spring.redis.xxx是对redis的配置
  • 连接工厂LettuceConnectionConfiguration、JedisConnectionConfiguration是准备好的。
  • 自动注入了RedisTemplate<Object, Object>,xxxTemplate。
  • 自动注入了StringRedisTemplate,key,value都是String
  • 底层只要我们使用StringRedisTemplate、RedisTemplate就可以操作Redis。

外网Redis环境搭建:

  1. 阿里云按量付费Redis,其中选择经典网络。

  2. 申请Redis的公网连接地址。

  3. 修改白名单,允许0.0.0.0/0访问。

  • Redis Desktop Manager:可视化Redis管理软件

2. RedisTemplate与Lettuce

测试redis连接:

@SpringBootTest
public class Boot05WebAdminApplicationTests {

    @Autowired
    StringRedisTemplate redisTemplate;

    @Autowired
    RedisConnectionFactory redisConnectionFactory;

    @Test
    void testRedis(){
        ValueOperations<String, String> operations = redisTemplate.opsForValue();
        operations.set("hello","world");

        String hello = operations.get("hello");
        System.out.println(hello);

        System.out.println(redisConnectionFactory.getClass());
    }
}

3. 切换至jedis

spring:
  redis:
#   url: redis://lfy:Lfy123456@r-bp1nc7reqesxisgxpipd.redis.rds.aliyuncs.com:6379
    host: r-bp1nc7reqesxisgxpipd.redis.rds.aliyuncs.com
    port: 6379
    password: lfy:Lfy123456
    client-type: jedis
    jedis:
      pool:
        max-active: 10
#   lettuce:# 另一个用来连接redis的java框架
#      pool:
#        max-active: 10
#        min-idle: 5

Redis操作与统计小实验:

  • URL统计拦截器
@Component
public class RedisUrlCountInterceptor implements HandlerInterceptor {

    @Autowired
    StringRedisTemplate redisTemplate;

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String uri = request.getRequestURI();
        //默认每次访问当前uri就会计数+1
        redisTemplate.opsForValue().increment(uri);
        return true;
    }
}
  • 注册URL统计拦截器:
@Configuration
public class AdminWebConfig implements WebMvcConfigurer{

    @Autowired
    RedisUrlCountInterceptor redisUrlCountInterceptor;

	@Override
    public void addInterceptors(InterceptorRegistry registry) {
        //将拦截器注册到容器中.拦截所有请求.放行的请求
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/","/login","/css/**","/fonts/**","/images/**","/js/**");
        registry.addInterceptor(redisUrlCountInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/","/login","/css/**","/fonts/**","/images/**",
                        "/js/**","/aa/**");
    }
}

Filter、Interceptor 几乎拥有相同的功能,都是拦截作用?

  • Filter是Servlet定义的原生组件,它的好处是脱离Spring应用也能使用。
  • Interceptor是Spring定义的接口,可以使用Spring的自动装配等功能。

调用Redis内的统计数据:

@Slf4j
@Controller
public class IndexController {

	@Autowired
    StringRedisTemplate redisTemplate;
    
	@GetMapping("/main.html")
    public String mainPage(HttpSession session,Model model){

        log.info("当前方法是:{}","mainPage");

        ValueOperations<String, String> opsForValue =
                redisTemplate.opsForValue();

        String s = opsForValue.get("/main.html");
        String s1 = opsForValue.get("/sql");

        model.addAttribute("mainCount",s);
        model.addAttribute("sqlCount",s1);

        return "main";
    }
}
第三章 SpringBoot数据访问 Spring Data是Spring提供的一个用于简化数据库访问、支持云服务的开源框架。它是一个伞形项目,包含了大量关系型数据库及非关系型数据库的数据访问解决方案,其设计目的是使我们可以快速且简单的使用各种数据访问技术。SpringBoot默认采用整合Spring Data的方式统一处理数据访问层,通过添加大量自动配置,引入各种数据访问模板xxxTemplate以及统一的Repository接口,从而达到简化数据访问层的操作。 阅读详情

相关推荐

SpringBoot入门实战:SpringBoot数据访问层实现

1.背景介绍 在一个Java应用中,通常会涉及到多个业务模块的开发,这些业务模块往往存在相互的数据交互,如用户模块和订单模块之间进行数据的查询、插入、修改、删除等操作。为了提高效率、降低耦合度,我们一般都会将这些数据交互模块抽象成一个数据访问层(DAO)。本文将详细介绍如何基于Spring Boot框架实现Spring Data JPA作为DAO层,以

AI天才研究院 428

Springboot—数据访问

目录 SQL: 自动配置分析: DataSourceAutoConfiguration:数据源的自动配置 JdbcTemplateAutoConfiguration: Druid数据源: DruidDataSourceAutoConfigure 然后我们看下关键的DruidStatProperties: DruidDataSourceAutoConfigure: yml全部: 自定义实现监控页与监控功能: SQL: 1.首先导入JDBC场景: <depen...

weixin_57128596的博客 1901

手把手教你用VCS+VERDI搭建数字IC验证环境(附Makefile避坑指南)

本文详细介绍了如何使用VCS编译器和VERDI调试工具搭建数字IC验证环境,涵盖从RTL设计到波形分析的全流程。重点解析了Makefile自动化构建、FSDB波形生成方法及常见问题解决方案,帮助工程师高效完成验证工作。特别提供了VCS编译参数配置和VERDI调试技巧的实用指南。

weixin_33738578的博客 451

SpringBoot动态数据源的使用

@TOCSpringBoot动态数据的使用 SpringBoot动态数据的使用 场景:系统运维工具,运维工具是运维工程师维护系统数据、功能正常的工具,常见的有:消息队列补偿工具、数据库同步失败稽查工具以及一些其他跟业务系统相关的工具。由于跟多个业务系统的打交道,在微服务的场景下,每一个微服务都有一个独立的数据库(地址及数据库名不同),这就需要运维工具在使用过程中能动态切换到正确的数据源上,对指定的微服务的数据库进行操作,当然使用Openfeign替代动态数据源也可以完成此类操作,具体可以平衡工作量及效率再做

qq_41340263的博客 1600

雾化器硬件设计:从N155驱动到PCB可量产实现

雾化器是典型的机电一体化嵌入式终端,其硬件设计本质是电源完整性、信号完整性与热-机械协同的系统工程。核心在于理解高压脉冲驱动原理(如2.4MHz固定频率匹配压电谐振)、电源域隔离机制(AGND/DGND/PGND分域设计)及约束驱动的PCB转化逻辑。技术价值体现在电气可靠性(如OTP/OLP保护)、生产可制造性(DFM合规焊盘与钢网)与环境鲁棒性(三防漆、散热过孔)。典型应用场景覆盖加湿器、医疗雾化仪与工业微流控设备。本文聚焦超声波雾化控制板的硬线实现路径,深入解析N155驱动芯片选型、网络标签工程误用陷阱

weixin_35649491的博客 620

AXI4-Stream FIFO IP核实战指南——从配置到跨时钟域处理

本文是AXI4-Stream FIFO IP核的实战指南,详细讲解了其作为数据流缓冲核心的作用。文章重点涵盖从Vivado环境下的IP核配置、关键参数(如深度与宽度)设定,到跨时钟域处理的完整流程。深入解析了TVALID/TREADY握手协议及TLAST等信号,并提供了常见问题排查与调试技巧,帮助开发者高效实现FPGA/SoC系统中可靠的数据流缓冲与同步。

weixin_29251567的博客 482

springboot访问数据库以json形式输出

springboot访问数据库以json形式输出 pojo中Test @Data @NoArgsConstructor @AllArgsConstructor public class Test { private Integer id; private String name; private Boolean gender; private Integer age; private Date birth; } TestMapper.xml <?xml ve

Airuiliya520的博客 1632

C# Socket网络通信UDP(关键字:Socket)

简单Socket-Udp通信 在本文中涉及到通信,仅做简单的通信(服务端接受消息,由客户端发出消息) 如有需要,根据需求可直接copy使用 关键字Socket 需要引用命名空间: using System.Net; using System.Net.Sockets; 服务端: using System; using System.Net; using System.Net.Sockets; u...

MelanceXin的博客 3890

Spring Boot如何访问不同的数据库

在Spring Boot中访问不同的数据库通常涉及到配置多个数据源以及可能的事务管理。

2401_87715607的博客 745

嵌入式系统中的轻量级压缩实践——miniLZO在STM32上的性能优化

本文深入探讨了miniLZO轻量级压缩算法在STM32嵌入式系统中的性能优化实践。通过对比无损压缩算法的性能特点,详细解析了miniLZO在内存占用、压缩速度方面的优势,并提供了STM32移植、参数调优及创新应用案例,帮助开发者在资源受限环境中实现高效数据压缩。

weixin_30776273的博客 85

SAP财务模块必看:BAPI_ACC_DOCUMENT_POST扩展字段全攻略(含FIBF配置)

本文详细解析了SAP财务模块中如何利用BAPI_ACC_DOCUMENT_POST的EXTENSION1参数扩展自定义字段。文章从需求分析入手,对比了传统增强与BTE(业务交易事件)两种技术路径,并重点提供了基于FIBF配置的完整实战指南,包括数据结构理解、函数模块开发及配置步骤,帮助ABAP开发者和财务顾问高效、可维护地实现如WBS元素、税务代码等字段的灵活传递。

weixin_29290963的博客 398

Spring Boot数据访问

Spring Boot数据访问 SpringBoot数据访问概述 1.创建数据库 create database springbootdata; 2.创建表 create table `t_article`( `id` int(20) NOT NULL AUTO_INCREMENT COMMENT '文章id', `title` varchar(200) DEFAULT NULL COMMENT '文章标题', `content` longtext COMMENT '文章内容', PRIMARY K

qq_45896330的博客 9812

【知识分享】车载以太网PCB布局设计指南

本文将深入探讨在设计车载以太网设备的印刷电路板(PCB)时需要着重考虑的若干关键主题。这些主题广泛涵盖了数据布线设计,以确保其符合信号完整性(SI)和电磁兼容性(EMC)标准;外部元器件的合理摆放;以及采取有效的抗电磁干扰(EMI)布局策略等方面。通过全面且细致地处理这些关键环节,能够显著提升车载以太网设备的性能与可靠性。

一只豌豆象的博客 1353

Spring Boot 数据访问

通过@Query注解自定义查询语句。Query;本文从零开始介绍了 Spring Boot 数据访问的完整实现,包括如何配置数据库连接、定义实体类、实现 CRUD 操作、以及复杂查询和事务管理。通过 Spring Data JPA,数据访问变得简单而强大。Spring Boot 的数据访问能力不仅适用于小型项目,也能扩展到复杂的企业级应用。

Flying_Fish_roe的博客 1297

自学 ABAP 和自学 SAP 的差别

有朋友在我的 ABAP 学习教程里留言: > 自学SAP是不是都要搭建虚拟服务器,然后自己去官网下载新版本SAP就可以吗 对于初学者,我们要搞清楚 ABAP 和 SAP 的区别。 ABAP 是一门编程语言,SAP 首先是德国软件公司的名称,也代表这家公司开发的一系列软件。SAP 公司开发的软件,我们有时也称产品,其功能能满足客户一个或者多个领域的业务需求。这些不同领域,我们也称为不同的业务模块,比如 ERP,CRM,SRM,HR 等等。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 6868

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

boot spring 插入一条数据_超详细讲解SpringBoot——数据访问

一、引言大部分系统都离不开数据访问,数据库包括SQL和NOSQL,SQL是指关系型数据库,常见的有SQL Server,Oracle,MySQL(开源),NOSQL是泛指非关系型数据库,常见的有MongoDB,Redis。用spring开发时我们常用的ORM框架有JDBC、Mybatis,Hibernate,现在最常用的应该是Mybatis。在Springboot中对于数据访问层,无论是SQL还是...

weixin_33273559的博客 3279

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

SpringBoot 数据访问

在xml中可以进行配置注入,同时也可以使用注解的方式。@Bean}}同时可以修改配置文件修改Druid的配置。但是这种方式较为麻烦,不建议使用。

JavaShark的博客 1979

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

SpringBoot——数据访问

一、SpringBoot的数据访问方式   对于数据访问层,无论是SQL还是NOSQL,SpringBoot默认采用整合SpringData的方式进行统一处理,添加大量自动配置,屏蔽了很多设置。引入各种XxxTemplate,XxxRepository来简化我们对数据访问层的操作。对我们来 说只需要进行简单的设置即可。 二、SpringBoot整合JDBC  1、创建项目,引入JDBC和Mysql...

如不來的博客 583

SpringBoot(四):Spring Boot的数据访问

1.基本概念 Spring Data 项目是Spring用来解决数据访问问题的一揽子解决方案,Spring Data是一个伞形项目,包含了大量关系型数据库和非关系型数据的数据访问解决方案。Spring Data使我们可以快速且简单的使用普通的数据访问技术及新的数据访问技术。 Spring Data包含的子项目: Spring Data JPA、Spring Data MongoDB、Spri...

鹏哥哥Aaa 438

详细SpringBoot教程之数据访问

写在前面 鉴于有人留言说想要学习SpringBoot相关的知识,我这里打算写一个SpringBoot系列的相关博文,目标呢是想让看了这一系列博文的同学呢,能够对SpringBoot略窥门径,这一系列的博文初步都定下来包括SpringBoot介绍、入门、配置、日志相关、web开发、数据访问、结合docker、缓存、消息队列、检索、任务安全、分布式等等一系列的博文,工作量很大,是个漫长的过程,每一步我...

BoCong-Deng的博客 1万+

springboot整合各种数据访问总结及原理

首先我们需要导入web和测试基础依赖包 Mysql驱动包 &amp;amp;lt;dependency&amp;amp;gt; &amp;amp;lt;groupId&amp;amp;gt;mysql&amp;amp;lt;/groupId&amp;amp;gt; &amp;amp;lt;artifactId&amp;amp;gt;mysql-connector-java&amp

wmh1152151276的博客 795
上一篇: Springboot——Web开发
下一篇: Springboot——其他核心功能
Curry_Java
博客等级 码龄5年 20粉丝 16原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值