在这里,我仍旧直接通过例子来解释怎么通过xml装配bean。
<?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:c="http://www.springframework.org/schema/c" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!--通过xml装配bean--> <!--步骤: 1.创建XML配置规范(即创建一个SpringXML文档) 2.声明bean(bean元素类似于JavaConfig中的@Bean注解) 3.注入bean