SpringBoot为了简化代码,提供了包扫描的机制,为包路径下的接口创建代理对象,之后交给spring容器管理,可以在任意位置依赖注入
@MapperScan("com.jt.mapper")
public class SpringBootRun {
public static void main(String[] args) {
SpringApplication.run(SpringBootRun.class,args);
}
}
本文介绍了SpringBoot如何通过@MapperScan注解实现接口的包扫描和代理对象创建,这些对象随后被加入到Spring容器中,允许在应用的任何地方进行依赖注入,以此达到代码的简化和模块化。
SpringBoot为了简化代码,提供了包扫描的机制,为包路径下的接口创建代理对象,之后交给spring容器管理,可以在任意位置依赖注入
@MapperScan("com.jt.mapper")
public class SpringBootRun {
public static void main(String[] args) {
SpringApplication.run(SpringBootRun.class,args);
}
}

被折叠的 条评论
为什么被折叠?
