关于springboot test@Mapper ,@Autiwired注入无效的问题

xiaoxiao2021-04-17  130

@SpringBootTest() @RunWith(SpringRunner.class) public class ProductMapperTest { @Autowired ProductMapper productMapper;

3:为了给mapper接口 自动根据一个添加@Mapper注解的接口生成一个实现类 怎么注入都是失败,ProductMapper 使用@Mapper 注解,这个不能注入到spring 容器中(其中原因还是不了解)。@Autowired 注入不进去的。

@Repository @Mapper public interface ProductMapper {

这下能注入容器中了。

转载请注明原文地址: https://www.6miu.com/read-4819667.html

最新回复(0)