junit看了很多教程 一启动就报错
1. 1.
<testResources>
<testResource>
<directory>src/main/resources</directory>
</testResource>
</testResources>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
几个junit的包也试过了
目测是数据库的驱动的jar包没有配置好造成的,具体你还是检查下配置。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringbootApplication.class)
public class MyTest {
@Autowired
private AES aes;
@Test
public void test(){
System.out.println(aes.encrypt("this is test"));
}
}
看下你的jdbc配置那里是不是dateType 没有配置
直接运行会报错,没有运行服务装载bean,手动装载一下
测试使用的类需要使用test目录下的配置文件,这里报错他告诉你你的datasource type没有指定,你看看是不是配置文件少了配置,比如:
spring:
datasource:
url: jdbc:mysql://192.168.163.163:3306/lix?useUnicode=true&characterEncoding=utf8
driverClassName: com.mysql.jdbc.Driver
username: name
password: xxxxxxx
type: com.zaxxer.hikari.HikariDataSource
项目结构中有test的环境配置么