Spring Boot集成My Batis之加载spring.xml文件

来源:互联网 发布:淘宝八斗学长考研资料 编辑:程序博客网 时间:2024/05/23 19:18

package cn.et.ssmboot;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.context.annotation.ImportResource;import org.springframework.transaction.annotation.EnableTransactionManagement;/** * @SpringBootApplication * 自动增加spring.xml文件,并且配置自动扫描 * 自动增加web.xml 同时在web.xml过滤器、拦截器... *  * @EnableAutoConfiguration要替换成@SpringBootApplication * 不然扫描不到dao层,装配不了EmpDaoImpl * 要装配的对象必须位于HelloController类共一个包或它的子包下才可以扫描的到 *  *  * @ImportResource(locations="classpath:/spring.xml") * 加载spring的配置文件,会自动加载spring里所有的bean * 也会自动配置 */@ImportResource(locations="classpath:/spring.xml")@SpringBootApplicationpublic class MyStarter {public static void main(String[] args) {//发布程序的方法入口SpringApplication.run(MyStarter.class, args);}}




原创粉丝点击