2012-05-09 27 views
22

Tôi đang cố gắng sử dụng util-liên tục cho IOC nhưng tôi nhận được thông báo lỗi sau:Java mùa xuân: Thông báo lỗi "không tuyên bố có thể được tìm thấy cho yếu tố 'util: liên tục'

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

Tất cả của lọ quận xuân 3.1.1 là trong classpath của tôi và tôi đã có thể chạy thành công chương trình của tôi trước khi thực hiện những thay đổi mà bao gồm việc sử dụng các util:. thẻ liên tục

Dưới đây là IOC file xml của tôi:


<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> 

Trả lời

53

Đây là tuyên bố đúng util namespace (đừng quên về cách xác định 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> 

Xem thêm tại C.2.2 The util schema.

+3

*** đừng quên chỉ định schemaLocation *** - cảm ơn :-) –

Các vấn đề liên quan