Java Spring:错误消息“无法为元素'util:constant'找到声明 [英] Java Spring: Error message "no declaration can be found for element 'util:constant'

查看:124
本文介绍了Java Spring:错误消息“无法为元素'util:constant'找到声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用util-constant for ioc但是我收到以下错误消息:

I'm trying to use util-constant for ioc but I'm getting the following error message:

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

所有的spring 3.1.1 dist jar都是在我的类路径中,我能够在进行包含使用util:constant标记的更改之前成功运行我的程序。

All of the spring 3.1.1 dist jars are in my classpath and I was able to successfully run my program prior to making the changes that included the use of the util:constant tag.

这是我的ioc xml文件:

Here's my ioc xml file:


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


推荐答案

这是正确的 util namespace(不要忘记指定 schemaLocation ):

This is the correct declaration of util namespace (don't forget about specifying 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使用模式

这篇关于Java Spring:错误消息“无法为元素'util:constant'找到声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆