读取sping配置文件

<beans>  
<bean id="person" class="org.linweihan.Student"></bean>
</beans>

上面是applicationContext.xml文件,下面通过ClassPathXmlApplicationContext来创建ApplicationContext

public class TestFactory {

@SuppressWarnings("static-access")
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
Person person = (Person)context.getBean("person");
System.out.println(person.getName());
}
}
阅读更多

没有更多推荐了,返回首页