第一章:思路

第二章:Mybatis - Spring 技术
- 官网。
- 相关技术之间版本匹配说明:

- Mybatis-Spring 的依赖:
<dependency><groupId>org.mybatis</groupId><artifactId>mybatis-spring</artifactId><version>2.0.6</version></dependency>
第三章:总体 SSM 整合所需依赖
- pom.xml
<!-- Mybatis 整合 Spring --><dependency><groupId>org.mybatis</groupId><artifactId>mybatis-spring</artifactId><version>2.0.6</version></dependency><!-- SpringMVC --><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>5.3.12</version></dependency><!-- Spring 持久化层所需依赖 --><dependency><groupId>org.springframework</groupId><artifactId>spring-orm</artifactId><version>5.3.12</version></dependency><!-- 日志 --><dependency><groupId>ch.qos.logback</groupId><artifactId>logback-classic</artifactId><version>1.2.7</version></dependency><!-- ServletAPI --><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>4.0.1</version><scope>provided</scope></dependency><!-- Spring5和Thymeleaf整合包 --><dependency><groupId>org.thymeleaf</groupId><artifactId>thymeleaf-spring5</artifactId><version>3.0.12.RELEASE</version></dependency><!-- Mybatis核心 --><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>3.5.7</version></dependency><!-- MySQL驱动 --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.25</version></dependency><!-- 数据源 --><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.2.8</version></dependency><!-- junit5 --><dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter-api</artifactId><version>5.8.1</version><scope>test</scope></dependency><!-- Spring 的测试功能 --><dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId><version>5.3.12</version></dependency><!-- Lombok --><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.22</version><scope>provided</scope></dependency>
第四章:配置数据源
4.1 创建 jdbc.properties
- jdbc.properties
jdbc.user=rootjdbc.password=123456jdbc.url=jdbc:mysql://localhost:3306/ssm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=truejdbc.driver=com.mysql.cj.jdbc.Driver
4.2 加入日志配置文件
- logback.xml
<?xml version="1.0" encoding="UTF-8"?><configuration debug="true"><!-- 指定日志输出的位置 --><appender name="STDOUT"class="ch.qos.logback.core.ConsoleAppender"><encoder><!-- 日志输出的格式 --><!-- 按照顺序分别是:时间、日志级别、线程名称、打印日志的类、日志主体内容、换行 --><pattern>[%d{HH:mm:ss.SSS}] [%-5level] [%thread] [%logger] [%msg]%n</pattern><charset>UTF-8</charset></encoder></appender><!-- 设置全局日志级别。日志级别按顺序分别是:DEBUG、INFO、WARN、ERROR --><!-- 指定任何一个日志级别都只打印当前级别和后面级别的日志。 --><root level="INFO"><!-- 指定打印日志的appender,这里通过“STDOUT”引用了前面配置的appender --><appender-ref ref="STDOUT" /></root><!-- 根据特殊需求指定局部日志级别 --><logger name="org.springframework.web.servlet.DispatcherServlet" level="DEBUG" /></configuration>
4.3 创建 Spring 的配置文件
- spring-persist.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd"><!-- 加载外部属性配置文件 --><context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder><!-- 配置数据源 --><bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"><property name="url" value="${jdbc.url}"/><property name="password" value="${jdbc.password}"/><property name="driverClassName" value="${jdbc.driver}"/><property name="username" value="${jdbc.user}"/></bean></beans>
4.3 创建 Junit 测试
package com.github.fairy.era;import lombok.extern.slf4j.Slf4j;import org.junit.jupiter.api.Test;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;import javax.sql.DataSource;/*** @author 许大仙* @version 1.0* @since 2021-11-22 09:25*/@SpringJUnitConfig(locations = {"classpath:spring-persist.xml"})@Slf4jpublic class SpringTest {@Autowiredprivate DataSource dataSource;@Testpublic void test() {log.info(" dataSource = " + dataSource);}}
第五章:配置 SqlSessionFactoryBean
5.1 创建 Mybatis 全局配置文件
- mybatis-config.xml
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE configurationPUBLIC "-//mybatis.org//DTD Config 3.0//EN""http://mybatis.org/dtd/mybatis-3-config.dtd"><configuration><!-- Mybatis全局配置 --><settings><!-- 将数据库表字段映射到驼峰式命名的Java实体类属性中 --><!-- 数据库表字段格式:单词_单词 --><!-- Java实体类属性:首字母小写的驼峰式命名 --><setting name="mapUnderscoreToCamelCase" value="true"/></settings></configuration>
5.2 数据库脚本
SET NAMES utf8mb4;SET FOREIGN_KEY_CHECKS = 0;-- ------------------------------ 创建数据库-- ----------------------------CREATE DATABASE IF NOT EXISTS `ssm` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;-- ------------------------------ 创建表-- ----------------------------DROP TABLE IF EXISTS `employee`;CREATE TABLE `employee` (`id` int(11) NOT NULL AUTO_INCREMENT,`last_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,`gender` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,`email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,PRIMARY KEY (`id`) USING BTREE) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;-- ------------------------------ 插入数据-- ----------------------------INSERT INTO `employee` VALUES (1, 'jerry', '男', 'jerry@qq.com');INSERT INTO `employee` VALUES (2, 'aa', '男', 'aa@11.com');INSERT INTO `employee` VALUES (3, 'bb', '男', 'bb@11.com');INSERT INTO `employee` VALUES (4, 'aa', '男', 'aa@11.com');INSERT INTO `employee` VALUES (5, 'bb', '男', 'bb@11.com');SET FOREIGN_KEY_CHECKS = 1;
5.3 创建实体类
- Employee.java
package com.github.fairy.era.entity;import lombok.Data;/*** @author 许大仙* @version 1.0* @since 2021-11-22 09:42*/@Datapublic class Employee {private Integer id;private String lastName;private String gender;private String email;}
5.4 创建 Mapper 接口
- EmployeeMapper.java
package com.github.fairy.era.mapper;import com.github.fairy.era.entity.Employee;import java.util.List;/*** @author 许大仙* @version 1.0* @since 2021-11-22 09:56*/public interface EmployeeMapper {List<Employee> findAll();}
5.5 创建 Mapper 配置文件
- EmployeeMapper.xml
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><!-- mapper是根标签。namespace属性是找到当前配置的依据 --><!-- 由于最理想的Mybatis使用方式是:通过Mapper接口调用接口方法,访问数据库 --><!-- 这样的理想方式要求:能够通过接口全类名找到Mapper配置 --><!-- 所以:我们就用Mapper接口的全类名来给namespace属性赋值 --><mapper namespace="com.github.fairy.era.mapper.EmployeeMapper"><select id="findAll" resultType="com.github.fairy.era.entity.Employee">SELECT id,last_name,gender,emailFROM employee</select></mapper>
5.6 配置 sqlSessionFactoryBean
5.6.1 保留 Mybatis 全局配置文件
- spring-persist.xml
<!-- 配置 sessionFactoryBean --><bean id="sessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean"><!-- 数据源 --><property name="dataSource" ref="dataSource"/><!-- 指定 Mybatis 全局配置文件位置 --><property name="configLocation" value="classpath:mybatis-config.xml"/><!-- 指定 Mapper 配置文件位置 --><property name="mapperLocations" value="classpath*:com/github/fairy/era/mapper/*Mapper.xml"/></bean>
- 完整的 spring-persist.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd"><!-- 加载外部属性配置文件 --><context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder><!-- 配置数据源 --><bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"><property name="url" value="${jdbc.url}"/><property name="password" value="${jdbc.password}"/><property name="driverClassName" value="${jdbc.driver}"/><property name="username" value="${jdbc.user}"/></bean><!-- 配置 sessionFactoryBean --><bean id="sessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean"><!-- 数据源 --><property name="dataSource" ref="dataSource"/><!-- 指定 Mybatis 全局配置文件位置 --><property name="configLocation" value="classpath:mybatis-config.xml"/><!-- 指定 Mapper 配置文件位置 --><property name="mapperLocations" value="classpath*:com/github/fairy/era/mapper/*Mapper.xml"/></bean></beans>
5.6.2 彻底舍弃 Mybatis 全局配置文件
- spring-persist.xml
<!-- 配置 sessionFactoryBean --><bean id="sessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean"><!-- 数据源 --><property name="dataSource" ref="dataSource"/><!-- 舍弃 Mybatis 全局配置文件,使用 configuration 属性 --><property name="configuration"><bean class="org.apache.ibatis.session.Configuration"><property name="mapUnderscoreToCamelCase" value="true"/></bean></property><!-- 指定 Mapper 配置文件位置 --><property name="mapperLocations" value="classpath*:com/github/fairy/era/mapper/*Mapper.xml"/></bean>
- 完整的 spring-persist.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd"><!-- 加载外部属性配置文件 --><context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder><!-- 配置数据源 --><bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"><property name="url" value="${jdbc.url}"/><property name="password" value="${jdbc.password}"/><property name="driverClassName" value="${jdbc.driver}"/><property name="username" value="${jdbc.user}"/></bean><!-- 配置 sessionFactoryBean --><bean id="sessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean"><!-- 数据源 --><property name="dataSource" ref="dataSource"/><!-- 舍弃 Mybatis 全局配置文件,使用 configuration 属性 --><property name="configuration"><bean class="org.apache.ibatis.session.Configuration"><property name="mapUnderscoreToCamelCase" value="true"/></bean></property><!-- 指定 Mapper 配置文件位置 --><property name="mapperLocations" value="classpath*:com/github/fairy/era/mapper/*Mapper.xml"/></bean></beans>
注意:上面两种方式如果并存,会抛出异常:java.lang.IllegalStateException: Property ‘configuration’ and ‘configLocation’ can not specified with together
5.7 配置 Mapper 接口的扫描器
5.7.1 使用扫描器
- spring-persist.xml
<!-- 配置 Mapper 接口 bean 的扫描器 --><bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="com.github.fairy.era.mapper"/></bean>
- 完整的 spring-persist.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd"><!-- 加载外部属性配置文件 --><context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder><!-- 配置数据源 --><bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"><property name="url" value="${jdbc.url}"/><property name="password" value="${jdbc.password}"/><property name="driverClassName" value="${jdbc.driver}"/><property name="username" value="${jdbc.user}"/></bean><!-- 配置 sessionFactoryBean --><bean id="sessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean"><!-- 数据源 --><property name="dataSource" ref="dataSource"/><!-- 舍弃 Mybatis 全局配置文件,使用 configuration 属性 --><property name="configuration"><bean class="org.apache.ibatis.session.Configuration"><property name="mapUnderscoreToCamelCase" value="true"/></bean></property><!-- 指定 Mapper 配置文件位置 --><property name="mapperLocations" value="classpath*:com/github/fairy/era/mapper/*Mapper.xml"/></bean><!-- 配置 Mapper 接口 bean 的扫描器 --><bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="com.github.fairy.era.mapper"/></bean></beans>
5.7.2 使用 mybatis-spring 名称空间
- spring-persist.xml
<!-- 使用 mybatis-spring 名称空间 --><mybatis-spring:scan base-package="com.github.fairy.era.mapper"/>
- 完整的 spring-persist.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring.xsd"><!-- 加载外部属性配置文件 --><context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder><!-- 配置数据源 --><bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"><property name="url" value="${jdbc.url}"/><property name="password" value="${jdbc.password}"/><property name="driverClassName" value="${jdbc.driver}"/><property name="username" value="${jdbc.user}"/></bean><!-- 配置 sessionFactoryBean --><bean id="sessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean"><!-- 数据源 --><property name="dataSource" ref="dataSource"/><!-- 舍弃 Mybatis 全局配置文件,使用 configuration 属性 --><property name="configuration"><bean class="org.apache.ibatis.session.Configuration"><property name="mapUnderscoreToCamelCase" value="true"/></bean></property><!-- 指定 Mapper 配置文件位置 --><property name="mapperLocations" value="classpath*:com/github/fairy/era/mapper/*Mapper.xml"/></bean><!-- 使用 mybatis-spring 名称空间 --><mybatis-spring:scan base-package="com.github.fairy.era.mapper"/></beans>
注意:两种方式任选一种即可。
5.8 测试
package com.github.fairy.era;import com.github.fairy.era.mapper.EmployeeMapper;import lombok.extern.slf4j.Slf4j;import org.junit.jupiter.api.Test;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;/*** @author 许大仙* @version 1.0* @since 2021-11-22 09:25*/@SpringJUnitConfig(locations = {"classpath:spring-persist.xml"})@Slf4jpublic class SpringTest {@Autowiredprivate EmployeeMapper employeeMapper;@Testpublic void test() {System.out.println("employeeMapper = " + employeeMapper);}}
第六章:加入声明式事务
6.1 配置事务管理器
- spring-persist.xml
<!-- 配置事务管理器 --><bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource"/></bean><!-- 开启基于注解的事务支持 --><tx:annotation-driven transaction-manager="transactionManager"/>
- 完整的 spring-persist.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"><!-- 加载外部属性配置文件 --><context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder><!-- 配置数据源 --><bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"><property name="url" value="${jdbc.url}"/><property name="password" value="${jdbc.password}"/><property name="driverClassName" value="${jdbc.driver}"/><property name="username" value="${jdbc.user}"/></bean><!-- 配置 sessionFactoryBean --><bean id="sessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean"><!-- 数据源 --><property name="dataSource" ref="dataSource"/><!-- 舍弃 Mybatis 全局配置文件,使用 configuration 属性 --><property name="configuration"><bean class="org.apache.ibatis.session.Configuration"><property name="mapUnderscoreToCamelCase" value="true"/></bean></property><!-- 指定 Mapper 配置文件位置 --><property name="mapperLocations" value="classpath*:com/github/fairy/era/mapper/*Mapper.xml"/></bean><!-- 使用 mybatis-spring 名称空间 --><mybatis-spring:scan base-package="com.github.fairy.era.mapper"/><!-- 配置事务管理器 --><bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource"/></bean><!-- 开启基于注解的事务支持 --><tx:annotation-driven transaction-manager="transactionManager"/></beans>
6.2 创建Service组件
- EmployeeService.java
package com.github.fairy.era.service;import com.github.fairy.era.entity.Employee;import java.util.List;/*** @author 许大仙* @version 1.0* @since 2021-11-22 12:38*/public interface EmployeeService {List<Employee> findAll();}
- EmployeeServiceImpl.java
package com.github.fairy.era.service.impl;import com.github.fairy.era.entity.Employee;import com.github.fairy.era.mapper.EmployeeMapper;import com.github.fairy.era.service.EmployeeService;import lombok.RequiredArgsConstructor;import org.springframework.stereotype.Service;import org.springframework.transaction.annotation.Transactional;import java.util.List;/*** @author 许大仙* @version 1.0* @since 2021-11-22 12:39*/@Service@Transactional(rollbackFor = Exception.class,readOnly = true)@RequiredArgsConstructorpublic class EmployeeServiceImpl implements EmployeeService {private final EmployeeMapper employeeMapper;@Overridepublic List<Employee> findAll() {return employeeMapper.findAll();}}
6.3 配置自动扫描的包
- spring-persist.xml
<!-- 配置自动扫描的包 --><context:component-scan base-package="com.github.fairy.era.service"/>
- 完整的 spring-persist.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"><!-- 加载外部属性配置文件 --><context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder><!-- 配置数据源 --><bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"><property name="url" value="${jdbc.url}"/><property name="password" value="${jdbc.password}"/><property name="driverClassName" value="${jdbc.driver}"/><property name="username" value="${jdbc.user}"/></bean><!-- 配置 sessionFactoryBean --><bean id="sessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean"><!-- 数据源 --><property name="dataSource" ref="dataSource"/><!-- 舍弃 Mybatis 全局配置文件,使用 configuration 属性 --><property name="configuration"><bean class="org.apache.ibatis.session.Configuration"><property name="mapUnderscoreToCamelCase" value="true"/></bean></property><!-- 指定 Mapper 配置文件位置 --><property name="mapperLocations" value="classpath*:com/github/fairy/era/mapper/*Mapper.xml"/></bean><!-- 使用 mybatis-spring 名称空间 --><mybatis-spring:scan base-package="com.github.fairy.era.mapper"/><!-- 配置事务管理器 --><bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource"/></bean><!-- 开启基于注解的事务支持 --><tx:annotation-driven transaction-manager="transactionManager"/><!-- 配置自动扫描的包 --><context:component-scan base-package="com.github.fairy.era.service"/></beans>
6.4 测试
package com.github.fairy.era;import com.github.fairy.era.service.EmployeeService;import lombok.extern.slf4j.Slf4j;import org.junit.jupiter.api.Test;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;/*** @author 许大仙* @version 1.0* @since 2021-11-22 09:25*/@SpringJUnitConfig(locations = {"classpath:spring-persist.xml"})@Slf4jpublic class SpringTest {@Autowiredprivate EmployeeService employeeService;@Testpublic void test() {employeeService.findAll().forEach(System.out::println);}}
