Spring3.0中支持的配置类和xml文件配置混合模式
1.在配置类中引入xml配置文件:
@Configuration
@ImportResource("classpath:spring-config.xml")
public class SpringConfig {
}
spring-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="strBean" class="java.lang.String" ></bean>
</beans>
测试类:
public class Demo1 {
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);