java web spring xsdはクラスパスからロードします。

2428 ワード

springにおけるプロファイル定義のdtd,xsdなどのファイルはデフォルトではファイル定義の場所からチェックをロードします。たとえば以下は普通のspirng構成です。
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-4.1.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd">
 
springを起動する時はインターネットに接続します。これではネットワークがよくないと起動できなくなります。クラスパスでローカルからロードすると問題が回避されます。ロードされたファイルはxsdファイルで、これらのファイルはspringのjarパケットの中で、クラスパスの配置時にjarパケットのパスが使えます。もちろん、より便利な方法はこれらのxsdファイルをsoruceディレクトリの下にコピーすることです。これらのxsdファイルは直接にネットからダウンロードできます。そして次の構成があります。
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        classpath:spring-beans-4.1.xsd
        http://www.springframework.org/schema/context 
        classpath:spring-context-4.1.xsd
        http://www.springframework.org/schema/mvc
        classpath:spring-mvc-4.1.xsd
        http://www.springframework.org/schema/aop classpath:spring-aop-4.1.xsd
        http://www.springframework.org/schema/tx classpath:spring-tx-4.1.xsd">