Spring ,无法解决占位符,有人可以解释我吗

标签 spring tomcat

我以前从未使用过 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

最佳答案

听起来您正在尝试在 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>

关于 Spring ,无法解决占位符,有人可以解释我吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19569004/

相关文章:

java - 有没有办法在 Java Spring 中将不可预测数量的 Monos 合并到列表中?

java - 当 IN 子句超过 100 或 1000 时,NamedParameterJdbcTemplate 不起作用

tomcat - 从 Grails 成功部署到 Tomcat 结果为 404 "resource not available"

tomcat - 维护授权状态

java - Grails:仅在生产 tomcat 服务器中运行时才出现 RestBuilder 异常

tomcat - 在 Netbeans 中自动部署 Liferay portlet

Spring循环依赖使用setter

spring - 如何在Spring框架的网页中列出数据库中的数据

java - 何时使用 Spring 原型(prototype)作用域?

IDE 无法识别 Tomcat 启动