- Spring框架:通过ClassPathXmlApplicationContext工厂读取配置文件applicationContent.xml。
- 获得配置文件中的bean标签的相关信息,通过反射创建对象。Class clazz = Class.forName(class的值)。
<?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 https://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="user" class="com.example.demo.pojo.User"> <property name="name" value="323"></property> </bean> <!-- more bean definitions go here --> </beans>
- 反射对象底层也会调用自己的构造方法(私有的构造也可以调用)。
spring 简单原理
最新推荐文章于 2024-09-10 10:21:38 发布