本次实验使用的MariaDB数据库,不使用MySQL,两者的使用方式是一样的,如果你电脑没有安装MariaDB,你应该先去安装。

添加数据库

数据库sql文件在项目的根目录下,自行添加到数据库。

项目下载地址:https://rookie1679.lanzoum.com/id5Rn0kn6z5a

添加依赖

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!--    mariadb数据库-->
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.1.0</version>
</dependency>
<!-- 数据库连接池管理器-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.15</version>
</dependency>
<!-- mybatis-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.7</version>
</dependency>
<!-- spring-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.2.10.RELEASE</version>
</dependency>
<!-- spring管理jdbc-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.2.10.RELEASE</version>
</dependency>
<!-- mybatis整合spring-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.0</version>
</dependency>

项目结构

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
E:.
├─java
└─site
└─hikki
App.java # 程序入口

├─config # 配置包
JdbcConfig.java
MybatisConfig.java
SpringConfig.java

├─entity # 实体类
Student.java

├─mapper # 数据层
StudentMapper.java

└─service # 服务层
StudentService.java

└─impl
StudentServiceImpl.java

└─resources # 项目资源
jdbc.properties # 数据库连接信息

新建数据库连接信息

在resource下新建jdbc.properties文件,并写入数据库连接信息。

username和password根据你自己电脑数据库用户来填写。

1
2
3
4
jdbc.driver=org.mariadb.jdbc.Driver
jdbc.url=jdbc:mariadb://localhost:3307/spring_db?useSSL=false
jdbc.username=root
jdbc.password=root

设置配置

在Spring项目中,我们首先是配置bean对象,好比我们之前使用xml文件时,我们创建好Spring项目时,也是先去新建SpringConfig.xml文件一样。配置完主配置(SpringConfig)类,还要配置第三方类(Mybatis),还有Jdbc配置类。

主配置类

配置主配置类,再导入第三方的配置类,分清主次,后续项目开发的结构会清晰很多。

  • @Configuration:表明该配置是配置类
  • @ComponentScan:表示扫描bean的范围,如果需要添加bean,则将bean对应的类放到扫描范围即可,如果有多个包,可以使用{param,param}数组进行分隔开。
  • @PropertySource:加载properties资源文件
  • @Import:导入第三方的bean,有多个用数组分隔开。
1
2
3
4
5
6
7
8
9
10
11
12
package site.hikki.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
@Configuration //设置该类是配置类
@ComponentScan("site.hikki.service") //扫描bean范围
@PropertySource("classpath:jdbc.properties") //导入properties文件
@Import({JdbcConfig.class, MybatisConfig.class}) // 导入第三方的bean
public class SpringConfig {
}

Jdbc配置类

我们在连接数据库时,用到了阿里巴巴开源的Druid连接池。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package site.hikki.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;
public class JdbcConfig {
@Value("${jdbc.driver}")
private String driver;
@Value("${jdbc.url}")
private String url;
@Value("${jdbc.username}")
private String username;
@Value("${jdbc.password}")
private String password;

// 第三方bean管理
@Bean
public DataSource dataSource(){
DruidDataSource ds = new DruidDataSource();
ds.setDriverClassName(driver);
ds.setUrl(url);
ds.setUsername(username);
ds.setPassword(password);
return ds;
}
}

Mybatis配置类

我们以前在使用mybatis时,我们都是使用Mybatis-Config.xml这么一个文件来管理我们的数据库连接,文件标签一大堆,总感觉很麻烦,Spring的出现,可以很好的帮我们解决这个问题,我们以前使用标签设置某个属性的值,现在可以直接调用某个方法来设置,设置起来方便许多。

mybatis配置文件关键的几个配置项一般就加载properties文件、配置包别名、配置数据库连接信息、扫描mapper位置等等。

配置包别名 & 加载数据库连接信息

  • 创建一个SqlSessionFactoryBean方法,所有配置信息都在该方法下进行设置。

  • 加载jdbc.properties文件,我们在主配置已经加载好了,所以这里就不需要重配置了。

  • <typeAliases>下的包标签我们使用setTypeAliasesPackage方法来实现,如果想对某个类来实现别名,我们可以使用setTypeAliases来实现对类进行别名。

  • 加载数据库信息,我们使用setDataSource来实现,dataSource是第三方的bean,是JdbcConfig配置类下的一个方法,我们可以在该方法中直接添加参数,Spring会帮我们自动注入。

1-mybatis配置文件分析

扫描mapper位置

mapper的扫描范围我们需要用到MapperScannerConfigurer方法,对MapperScannerConfigurer()实例化,添加mapper包的位置。

2-mybatis配置文件分析

案例代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package site.hikki.config;

import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.Bean;
import javax.sql.DataSource;

public class MybatisConfig {

@Bean
public SqlSessionFactoryBean sqlSessionFactoryBean(DataSource dataSource){
SqlSessionFactoryBean ssfb = new SqlSessionFactoryBean();
ssfb.setTypeAliasesPackage("site.hikki.entity");
ssfb.setDataSource(dataSource);
return ssfb;
}

@Bean
public MapperScannerConfigurer mapperScannerConfigurer(){
MapperScannerConfigurer msc = new MapperScannerConfigurer();
msc.setBasePackage("site.hikki.mapper");
return msc;
}
}

实体类

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package site.hikki.entity;

public class Student {
private String num;
private String name;
private String age;
private String major;
@Override
public String toString() {
return "Student{" +
"num='" + num + '\'' +
", name='" + name + '\'' +
", age='" + age + '\'' +
", major='" + major + '\'' +
'}';
}

public String getNum() {
return num;
}

public void setNum(String num) {
this.num = num;
}

public String getName() {
return name;
}

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

public String getAge() {
return age;
}

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

public String getMajor() {
return major;
}

public void setMajor(String major) {
this.major = major;
}
}

编写mapper

site.hikki.mapper包下新建一个StudentMapper接口,写入内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package site.hikki.mapper;

import org.apache.ibatis.annotations.*;
import site.hikki.entity.Student;

import java.util.List;

public interface StudentMapper {
/**
* 查询全部学生信息
* @return
*/
@Select("select * from tb_student")
List<Student> find();

/**
* 根据num查询学生信息
* @param num
* @return
*/
@Select("select * from tb_student where num=#{num}")
Student findByNum(@Param("num") String num);

/**
* 添加学生信息
* @param student
* @return
*/
@Insert("insert into tb_student (num,name,age,major) value(#{num},#{name},#{age},#{major})")
int addStudent(Student student);

/**
* 根据num删除学生信息
* @param num
* @return 返回更新条数
*/
@Delete("delete from tb_student where num =#{num}")
int delStudentBynum(@Param("num") String num);

/**
* 根据num更新姓名
* @param num
* @param name
* @return
*/
@Update("update tb_student set name = #{name} where num = #{num}")
int updateStudentBynum(@Param("name") String name, @Param("num") String num);
}

编写服务层

site.hikki.service下编写服务层

服务层接口

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package site.hikki.service;

import site.hikki.entity.Student;
import java.util.List;

public interface StudentService {
List<Student> find();

Student findByNum(String num);

int addStudent(Student student);

int delStudentBynum(String num);

int updateStudentBynum(String name,String num);
}

实现方法

  1. 设置该服务类为bean(建议使用@Service),如果没有指定bean名称,则默认使用studentService
  2. 添加StudentMapper属性,并且配置自动注入
  3. 实现StudentService方法,并且返回StudentMapper的接口方法

我们添加了StudentMapper的属性,使用 @Autowired后会自动装配,好比以前使用new StudentMapper()是一样的,只是现在spring帮我们new了对象,不需要我们自己new了。

回顾之前学习内容:配置某类是bean对象,有三个注解都可以实现,三个注解表示的意思是一样的,我们常常将他们区分开始为了更好的理解代码,理解当前的bean是作用,提高开发效率。

  • @Controller:控制器(注入服务)。
  • @Repository:dao持久层(实现dao访问),标注数据访问组件。
  • @Service:service服务层(注入dao),处理业务逻辑。
  • @component: 标注一个类为Spring容器的Bean,(把普通pojo实例化到spring容器中,相当于配置文件中的<bean id="" class=""/>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package site.hikki.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import site.hikki.entity.Student;
import site.hikki.mapper.StudentMapper;
import site.hikki.service.StudentService;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
@Autowired
private StudentMapper studentMapper;

@Override
public List<Student> find() {
return studentMapper.find();
}

@Override
public Student findByNum(String num) {
return studentMapper.findByNum(num);
}

@Override
public int addStudent(Student student) {
return studentMapper.addStudent(student);
}

@Override
public int delStudentBynum(String num) {
return studentMapper.delStudentBynum(num);
}

@Override
public int updateStudentBynum(String name, String num) {
return studentMapper.updateStudentBynum(name,num);
}
}

程序入口

按照以往的使用一样,加载主配置项,创建Ioc容器,获取到服务类的bean,然后调用服务类下的方法即可。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package site.hikki;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import site.hikki.config.SpringConfig;
import site.hikki.entity.Student;
import site.hikki.service.StudentService;
import java.util.List;

public class App {
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SpringConfig.class);
StudentService bean = ctx.getBean(StudentService.class);
List<Student> students = bean.find(); // 查询全部学生信息
for (Student s :students) {
System.out.println(s);
}
}
}

在以前使用mybatis时,对数据进行增删改查时,我们都需要对SqlSession进行clone或者commit,但使用了spring就不需要这一步了,我猜想可能是我们使用SqlSessionFactoryBean时,spring帮我们实现了。

Junit4测试

导包

Spring有整合Junit测试的方法,方便我们进行项目测试。

首先我们先导入一些相关依赖:

1
2
3
4
5
6
7
8
9
10
11
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.2.10.RELEASE</version>
</dependency>

测试步骤

步骤 方法 备注
第一步 @RunWith(SpringJUnit4ClassRunner.class) 设置类运行器
第二步 @ContextConfiguration(classes = SpringConfig.class) 运行环境
第三步 @Autowired
private StudentService studentService;
引用类型注入
第四步 @Test public void find() {} 编写测试方法

注意:在导包时要导入import org.junit.Test,不要导错包了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package site.hikki.service;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import site.hikki.config.SpringConfig;
import site.hikki.entity.Student;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class) //1.设置类运行器
@ContextConfiguration(classes = SpringConfig.class) // 2.运行环境
public class StudentServiceTest2 {

@Autowired // 3. 引用类型注入
private StudentService studentService;

@Test // 4.编写测试方法
public void find() {
List<Student> students = studentService.find();
for (Student s :students) {
System.out.println(s);
}
}

@Test
public void findByNum() {
Student student = studentService.findByNum("1");
System.out.println(student);
}

@Test
public void addStudent() {
Student student = new Student();
student.setName("小码同学");
student.setAge("20");
student.setMajor("计算机科学与技术");
int i = studentService.addStudent(student);
System.out.println(i);
}

@Test
public void delStudentBynum() {
int i = studentService.delStudentBynum("3");
System.out.println(i);
}

@Test
public void updateStudentBynum() {
int i = studentService.updateStudentBynum("小码公众号叫:小码同学", "5");
System.out.println(i);
}
}
可能会遇到的错误

错误1:java.lang.Exception: Method XXX() should be public

1
java.lang.Exception: Method findByNum() should be public

解决方法:根据提示,在findByNum()方法前添加public即可

错误2:java.lang.Exception: No runnable methods

从错误中提炼出主要错误信息:

  1. 警告: Runner org.junit.internal.runners.ErrorReportingRunner (used on class site.hikki.service.StudentServiceTest2) does not support filtering and will therefore be run completely.
  2. java.lang.Exception: No runnable methods
  3. java.lang.NullPointerException

分析:

原因是导错了,原来导入的包是import org.junit.jupiter.api.Test;,junit版本对应错误 你在pom里的junit和@Test的junit版本不一致 在@Test时选择maven下的版本就可以了,不要选带api的,还有SpringJUnit4ClassRunner只支持4.12版本及以上。

解决方法:

将改import org.junit.jupiter.api.Test;import org.junit.Test;即可正常运行

错误内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
1月 10, 2023 12:37:55 下午 org.junit.vintage.engine.descriptor.RunnerTestDescriptor warnAboutUnfilterableRunner
警告: Runner org.junit.internal.runners.ErrorReportingRunner (used on class site.hikki.service.StudentServiceTest2) does not support filtering and will therefore be run completely.

java.lang.Exception: No runnable methods

at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:191)
at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:128)
at org.junit.runners.ParentRunner.validate(ParentRunner.java:416)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:84)
at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:65)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:137)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.vintage.engine.discovery.DefensiveAllDefaultPossibilitiesBuilder$DefensiveAnnotatedBuilder.buildRunner(DefensiveAllDefaultPossibilitiesBuilder.java:114)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.vintage.engine.discovery.DefensiveAllDefaultPossibilitiesBuilder.runnerForClass(DefensiveAllDefaultPossibilitiesBuilder.java:57)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.vintage.engine.discovery.ClassSelectorResolver.resolveTestClass(ClassSelectorResolver.java:66)
at org.junit.vintage.engine.discovery.ClassSelectorResolver.resolve(ClassSelectorResolver.java:47)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.lambda$resolve$2(EngineDiscoveryRequestResolution.java:134)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1632)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:185)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:125)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.access$100(EngineDiscoveryRequestResolution.java:57)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution$DefaultContext.resolve(EngineDiscoveryRequestResolution.java:224)
at org.junit.vintage.engine.discovery.MethodSelectorResolver.resolveParentAndAddFilter(MethodSelectorResolver.java:56)
at org.junit.vintage.engine.discovery.MethodSelectorResolver.resolve(MethodSelectorResolver.java:40)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.lambda$resolve$2(EngineDiscoveryRequestResolution.java:146)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1632)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:185)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:125)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:91)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.run(EngineDiscoveryRequestResolution.java:82)
at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver.resolve(EngineDiscoveryRequestResolver.java:113)
at org.junit.vintage.engine.discovery.VintageDiscoverer.discover(VintageDiscoverer.java:42)
at org.junit.vintage.engine.VintageTestEngine.discover(VintageTestEngine.java:64)
at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:152)
at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverSafely(EngineDiscoveryOrchestrator.java:134)
at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:108)
at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:80)
at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:110)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)


java.lang.NullPointerException
at site.hikki.service.StudentServiceTest2.find(StudentServiceTest2.java:22)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:214)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:210)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)