@ImportResouce注解加载XML配置文件
编写application-bean.xml注入bean;
在
src/main/resouces
下编写配置文件application-bean.xml
文件
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
/**
* classpath路径:locations={"classpath:application-bean1.xml","classpath:application-bean2.xml"}
* file路径: locations = {"file:d:/test/application-bean1.xml"};
*/
@Configuration
@ImportResource(locations={"classpath:application-bean.xml"})
//@ImportResource(locations={"file:d:/test/application-bean1.xml"})
public class ConfigClass {
}