当前位置:网站首页>Fundamentals - integrating third-party technology
Fundamentals - integrating third-party technology
2022-07-08 01:01:00 【Printf ('xiaobai ');】
Integrating third party Technology
Integrate Junit
Import the corresponding test starter
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
Test use @SpringBootTest modification
@SpringBootTest
class Springboot03JunitApplicationTests {
// Inject the object you want to test
@Autowired
private BookDao bookDao;
@Test
public void testBookDao(){
bookDao.save();
}
}
classes Property specifies the boot class
- When your test class is under the package and sub package of your boot class, it can be implemented
- When not under a bag , Will explode, will not find the configuration class , But the annotation of the boot class contains the annotation of the configuration class
@SpringBootTest(classes = Springboot03JunitApplicationTests.class)
perhaps
@SpringBootTest
@ContextConfiguration(classes = Springboot03JunitApplicationTests.class)
Integrate MyBatis
establish SpringBoot Engineering time , Add the corresponding module (MyBatis MySQL)
- MySQL Driver
- MyBatis framework modular
Set data source parameters
- Configure data source information
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/mybatis?serverTimezone=UTC
username: root
password: 123456
Define data layer interfaces and mappings ( You can use the configuration file xml form )
- Mapper It is to make the container recognize SQL mapping
@Mapper
public interface BookDao {
@Select("select * from t_book where id = #{id}")
public Book getById(Integer id);
}
test
@SpringBootTest
class Springboot03MyBatisApplicationTests {
@Autowired
private BookDao bookDao;
@Test
public void testGetById(){
Book book = bookDao.getById(1);
System.out.println(book);
}
}
Handling of common problems
- Server time zone setting processing
- mysql8 The time zone must be set for the above
Drive out reminder com.mysql.cj.jdbc.Driver
- mysql8 The time zone must be set for the above
Integrate MyBatis-Plus
add to pom rely on
- The official version is not included mybatis-plus, Alibaba templates can be used to create
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.2</version>
</dependency>
mapper Interface inheritance BaseMapper
@Mapper
public interface BookDao extends BaseMapper<Book> {
}
matters needing attention
- When there are no coordinates to choose, you need to manually add coordinate dependencies
- There are two ways to solve the problem that there is no table name
- The first is to add @TableName(“ Table name ”)
The second is to prefix the table name in the configuration file
- The first is to add @TableName(“ Table name ”)
mybatis-plus:
global-config:
db-config:
table-prefix: t_
Integrate Druid
Import coordinates
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.8</version>
</dependency>
To configure yml
- The first one is
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/mybatis?serverTimezone=UTC
username: root
password: 123456
type: com.alibaba.druid.pool.DruidDataSource
- The second kind (
recommend)
spring:
datasource:
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/mybatis?serverTimezone=UTC
username: root
password: 123456
Ge integrates third-party technology
- Import corresponding starter
- According to the configuration format provided , Configure the configuration items corresponding to non default values
边栏推荐
- Invalid V-for traversal element style
- Prediction of the victory or defeat of the League of heroes -- simple KFC Colonel
- [necessary for R & D personnel] how to make your own dataset and display it.
- 英雄联盟胜负预测--简易肯德基上校
- C#中string用法
- QT establish signal slots between different classes and transfer parameters
- 接口测试进阶接口脚本使用—apipost(预/后执行脚本)
- 基于卷积神经网络的恶意软件检测方法
- Basic mode of service mesh
- 12.RNN应用于手写数字识别
猜你喜欢

letcode43:字符串相乘

FOFA-攻防挑战记录

【GO记录】从零开始GO语言——用GO语言做一个示波器(一)GO语言基础

A network composed of three convolution layers completes the image classification task of cifar10 data set

接口测试进阶接口脚本使用—apipost(预/后执行脚本)

第四期SFO销毁,Starfish OS如何对SFO价值赋能?

接口测试要测试什么?

ThinkPHP kernel work order system source code commercial open source version multi user + multi customer service + SMS + email notification

AI遮天传 ML-回归分析入门

《因果性Causality》教程,哥本哈根大学Jonas Peters讲授
随机推荐
jemter分布式
5.过拟合,dropout,正则化
What has happened from server to cloud hosting?
14.绘制网络模型结构
Where is the big data open source project, one-stop fully automated full life cycle operation and maintenance steward Chengying (background)?
利用GPU训练网络模型
NVIDIA Jetson测试安装yolox过程记录
Qt不同类之间建立信号槽,并传递参数
Application practice | the efficiency of the data warehouse system has been comprehensively improved! Data warehouse construction based on Apache Doris in Tongcheng digital Department
Cascade-LSTM: A Tree-Structured Neural Classifier for Detecting Misinformation Cascades(KDD20)
They gathered at the 2022 ecug con just for "China's technological power"
Su embedded training - C language programming practice (implementation of address book)
炒股开户怎么最方便,手机上开户安全吗
Langchao Yunxi distributed database tracing (II) -- source code analysis
【深度学习】AI一键换天
Which securities company has a low, safe and reliable account opening commission
NVIDIA Jetson test installation yolox process record
22年秋招心得
【愚公系列】2022年7月 Go教学课程 006-自动推导类型和输入输出
12.RNN应用于手写数字识别