1、
Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils.getDefaultClassLoader()Ljava/lang/ClassLoader;
在pom.xml的依赖中,仔细查看控制台输出你会发现IntelliJ IDEA正在尝试使用JUnit5运行我的测试用例,希望使用JUnit4.12运行测试用例,我们查看pom.xml发现junit-jupiter-api这个依赖会导致这个错误
删除junit-jupiter-api pom文件中
2、
java.lang.IllegalStateException: Could not load TestContextBootstrapper [null]. Specify @BootstrapWith's 'value' attribute or make the default bootstrapper class available.
Pom文件中只留:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
3、打包失败:
Pom文件中添加:
<build> |
为springboot应用提供了执行maven操作的可能
打包为可执行的jar或war,命令:
mvn package spring-boot:repackage
4、注入mapper
启动类中添加对mapper包扫描@MapperScan(“com.……mapper”),这样无须在每个mapper上都加@Mapper注解
关于mapper这篇博客写的很好,发现自己用混了但是要是改过来说找不到类,可能有其他的问题吧,我再看看