Spring初始
IOC控制反转
Spring
IoC是对象管理的基础
maven导入Spring:<dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.2.6.RELEASE</version> </dependency>
在resources下新建applicationContext.xml文件
applicationContext.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
https://www.springframework.org/schema/beans/spring-beans.xsd">
获取applicationContext中实例化的对象:
ApplicationContext context = new ClassPathXmlApplicationCont