春天,无法解决占位符,有人可以解释一下

时间:2013-10-24 14:39:40

标签: spring tomcat

我以前从未使用过spring或者甚至没有使用过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 log 信息:关闭Spring根WebApplicationContext

2 个答案:

答案 0 :(得分:2)

听起来您正试图在Spring配置中使用外部属性,但没有正确配置的PropertyPlaceholderConfigurer bean。请参阅本教程: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>

答案 1 :(得分:0)

将以下行放在属性文件

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