1

我以前从未使用过spring,甚至没有学过它,在我的工作场所,当我在tomcat中运行应用程序时,我收到以下错误。我不明白,这是什么意思。占位符在$ {}中的值。.应用程序中没有错误,我在日志文件中收到此错误

org.springframework.beans.factory.BeanDefinitionStoreException:名称无效的bean定义“”,在类路径资源[SpringIntegration.xml]中定义:无法解析占位符“”

日志文件:

Oct 25, 2013 10:40:23 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Oct 25, 2013 10:40:26 AM org.apache.catalina.core.ApplicationContext log
INFO: StartupServlet: Executing StartupServlet.init()
Oct 25, 2013 10:40:26 AM org.apache.catalina.core.ApplicationContext log
INFO: StartupServlet: StartupServlet.init() successfully executed
Oct 25, 2013 10:40:29 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Oct 25, 2013 10:40:30 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'CWSJMSClient' defined in class path resource [SpringIntegration.xml]: Could not resolve placeholder 'VHF.CWS.Hybrid.Contract.RequestQueue'
    at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:287)
    at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:663)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:638)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:968)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1646)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

2013 年 10 月 25 日上午 10:40:30 org.apache.catalina.core.ApplicationContext 日志信息:关闭 Spring 根 WebApplicationContext

4

2 回答 2

2

听起来您正在尝试在 spring 配置中使用外部属性,但没有正确配置的PropertyPlaceholderConfigurerbean。参考本教程:http ://www.mkyong.com/spring/spring-propertyplaceholderconfigurer-example/

在那里,您将找到有关如何声明包含变量配置的属性文件的详细说明,例如:

database.username=myusername
database.password=mypassword
...

然后,您使用以下命令引用该文件PropertyPlaceholderConfigurer

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location">
        <value>database.properties</value>
    </property>
</bean>
于 2013-10-24T16:27:44.710 回答
0

将以下行放入属性文件

VHF.CWS.Hybrid.Contract.RequestQueue=jms://localhost:636

于 2013-10-26T08:29:19.647 回答