方式一:在所有mapper接口使用@Mapper注解
@Mapper
(将包中的所有接口都标注为DAO层接口)
public interface UserMapper {
UserInfo getUserInfo(@Param("userId") String userId);
}
方式二:在springboot的启动类使用@MapperScan注解
(作用:将指定包中的所有接口都标注为DAO层接口,相当于在每一个接口上写@Mapper)
@SpringBootApplication
@MapperScan(basePackages = "com.xiami.springboot.sbootdemo.mapper")
public class SbootdemoApplication {
@Autowired
private ApplicationArguments applicationArguments;
public static void main(String[] args) {
SpringApplication.run(SbootdemoApplication.class, args);
}
}