一、前言
本文承接上一节:Spring_总结_03_装配Bean(二)之Java配置
上一节说到,当需要显示配置时,首选类型安全并且比XML更强大Java配置。
那什么时候使用XML配置呢?
(1)维护已有XML配置
(2)想使用便利的XML命名空间,并且在JavaConfig中没有同样的实现。
二、引入schema
<?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 http://www.springframework.org/schema/beans/spring-beans.xsd"> </beans>