2012-05-09 16 views
22

Sto cercando di utilizzare util-costante per ioc ma sto ottenendo il seguente messaggio di errore:Java Primavera: Messaggio di errore "nessuna dichiarazione può essere trovata per l'elemento 'util: costante'

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

Tutto della molla 3.1.1 vasetti dist sono nel mio percorso di classe e sono stato in grado di eseguire correttamente il mio programma prima di effettuare i cambiamenti che includevano l'uso del util:. tag costante

Ecco la mia CIO file 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> 

risposta

53

Questa è la corretta dichiarazione di util dello spazio dei nomi (non dimenticate di specificare 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> 

saperne di più visita C.2.2 The util schema.

+3

*** non dimenticare di specificare schemaLocation *** - grazie :-) –

Problemi correlati