20

春が初めてなので、次のエラーを解決するのを手伝ってくれる人はいますか?

cvc-complex-type.2.4.c: The matching wildcard is strict, but no         
declaration can be found for element 'context:property-placeholder'.

applicationContext.xml に次の構成があります。

<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans       
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
xmlns:context="http://www.springframework.org/schema/context">

<bean id="dataSource"class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<context:property-placeholder location="src/jdbc.properties"/>
4

3 に答える 3

42

Springは、tx(トランザクション)、util(utils)、mvc(spring MVC宣言)などの簡単な方法を提供する一連の追加の名前空間を提供します。

1つを使用するには、XMLファイルでスキーママッピングを設定する必要があります。これを行うと、基本的なコード補完が得られます(IDEがさらに提供する場合があります)。。

あなたの宣言の文脈では、設定/マッピングされていませんでした。

宣言を次のように変更します。

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


</beans>

必要に応じて、社内コンポーネント用に独自の名前空間を設定することもできます。

于 2013-01-28T07:26:17.553 に答える