2012-05-09 52 views
22

我想UTIL常數使用國際奧委會,但我發現了以下錯誤消息:Java的春天:錯誤消息「沒有聲明可以發現元素‘UTIL:常量’

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

所有春天3.1.1 DIST罐子都在我的類路徑,我是能夠成功地製作,其中包括使用UTIL的變化之前,運行我的程序:常量標籤

這是我的國際奧委會XML文件:


<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" 
xmlns:tool="http://www.springframework.org/schema/tool" 
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> 


<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
    <property name="locations"> 
     <value>classpath:config.properties</value> 
    </property> 
</bean> 

<bean id="main" class="pikefin.Main"> 
<property name="executorSample" ref="executorSample"/> 
</bean> 


<bean id="executorSample" class="pikefin.ExecutorSample"> 
    <constructor-arg ref="threadPoolExecutor" /> 

</bean> 


<bean id="threadPoolExecutor" class="java.util.concurrent.ThreadPoolExecutor"> 
    <constructor-arg index="0" value="2"/> 
    <constructor-arg index="1" value="2"/> 
    <constructor-arg index="2" value="10"/> 
    <constructor-arg index="3"><util:constant static-field="java.util.concurrent.TimeUnit.SECONDS"/></constructor-arg> 
    <constructor-arg index="4" ref="arrayBlockingPool"/> 
</bean> 

<bean id="arrayBlockingPool" class="java.util.concurrent.ArrayBlockingQueue"> 
    <constructor-arg value="5"/> 
</bean> 

</beans> 

回答

53

這是util命名空間的正確的聲明(不要忘了指定schemaLocation):

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


</beans> 

多見於C.2.2 The util schema

+3

***不要忘記指定schemaLocation *** - 謝謝:-) –

相關問題