1. 程式人生 > >Spring xml配置檔案標頭

Spring xml配置檔案標頭



一般格式:此標頭滿足bean注入的格式  一般只有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"
    xsi:schemaLocation="
http://www.springframework.org/schema/beans
       

http://www.springframework.org/schema/beans/spring-beans.xsd">

新增aop的名稱空間,跟XSD的標頭:可引用aop標籤了!

<?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:aop="http://www.springframework.org/schema/aop

"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/aop
       
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
">

添加註解後的格式:

<?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
      xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context-3.0.xsd">  
 </beans>