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

来源:互联网 发布:韩国出口数据 编辑:程序博客网 时间:2024/06/06 01:16
  1.   
  2. import org.springframework.boot.SpringApplication;  
  3. import org.springframework.boot.autoconfigure.SpringBootApplication;  
  4. import org.springframework.context.annotation.ImportResource;  
  5. import org.springframework.transaction.annotation.EnableTransactionManagement;  
  6.   
  7. /** 
  8.  * @SpringBootApplication 
  9.  * 自动增加spring.xml文件,并且配置自动扫描 
  10.  * 自动增加web.xml 同时在web.xml过滤器、拦截器... 
  11.  *  
  12.  * @EnableAutoConfiguration要替换成@SpringBootApplication 
  13.  * 不然扫描不到dao层,装配不了EmpDaoImpl 
  14.  * 要装配的对象必须位于HelloController类共一个包或它的子包下才可以扫描的到 
  15.  *  
  16.  *  
  17.  * @ImportResource(locations="classpath:/spring.xml") 
  18.  * 加载spring的配置文件,会自动加载spring里所有的bean 
  19.  * 也会自动配置 
  20.  */  
  21. @ImportResource(locations="classpath:/spring.xml")  
  22. @SpringBootApplication  
  23. public class MyStarter {  
  24.       
  25.     public static void main(String[] args) {  
  26.         //发布程序的方法入口  
  27.         SpringApplication.run(MyStarter.class, args);  
  28.     }  
  29. }