在一个由@Configuration注解的配置类中通过@Autowired的方式注入一个SQL mapper类,需要在配置类或配置类的依赖中使用@MapperScan指定Mapper类所在包。
package com.test.service;
public interface SQLMapper {
@Select("Select * from test")
List<Msg> select();
}
@Configuration
@MapperScan({"com.test.service"})
public class TestConfig {
@Autowired
private SQLMapper mapper;
}