【1】解决springboot测试类无法注入的问题

416 阅读1分钟

1.在springboot中无法注入(Autowired失效) 判断时候少依赖包

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>

2.去除其他的test依赖包

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-test</artifactId>
    <scope>test</scope>
</dependency>

3.也可以去除unint测试包 spring-boot-starter-test自带测试包