applicationContext讲解
生成bean 豆子,bean工厂,对象的工厂
id是对象名,豆子的名字,全项目唯一,class是类全路径名
bean标签的底层实现是无参构造方法
<bean id="book1" class="com.nz.entity.Book">
加载Spring主配置文件套路代码
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
前期applicationContext代码
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> </beans>