8

以下のすべての xmlns と xsi:schemaLocation が以下のスプリング コンテキスト ファイルに必要ですか?

    <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"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:oxm="http://www.springframework.org/schema/oxm"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
            http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
            http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">

    <context:annotation-config />

    <bean class="org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping" />

    <bean id = "controller" class="simpleController"/>


</beans>

Bean クラスを定義しているだけなので、

xmlns="http://www.springframework.org/schema/beans" and its corresponding schema location enough ? 

他の定義は必要ありませんか? そうでない場合、いつこれらの定義を使用する必要がありますか?

4

3 に答える 3

6

必要な名前空間は 2 つだけです。

  • デフォルトのもの:
  • およびコンテキスト名前空間

その他の名前空間は、アプリケーション コンテキスト XML で削除できます。

さらに、バージョン固有の XSD ではなく、デフォルトの XSD を指定することをお勧めします。

<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.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context.xsd">
于 2013-06-10T10:49:57.437 に答える
1
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:util="http://www.springframework.org/schema/util"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context.xsd">

</beans>
于 2016-08-26T06:45:51.267 に答える