Could not resolve placeholder | Spring Placeholder

I am trying to use Spring <context:property-placeholder> in my application for first time and encountering some issues, I have tried many things as well already Google and have seems few posts over SO.

I am having a web application and need to pass some keys to underlying Class, was thinking of using place holder for same.Here is the structure of my application


I have a file which is inside resource folder, this is how I am trying

<context:property-placeholder location="classpath:resources/" />
<beans:bean id="reCaptcha" class="net.tanesha.recaptcha.ReCaptchaImpl">
  <beans:property name="privateKey" value="${demo.recapatcha_private_key}"/>
   <beans:property name="publicKey" value="${demo.recapatcha_public_key}"/>

But I am getting following exception on server startup

org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'reCaptcha' defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]: Could not resolve placeholder 'demo.recapatcha_private_key'

I have already tried placing file at various location which includes inside WEB-INF/classes and few other location at webapp but with no success.not sure what I am doing wrong


It sounds as though you're using a Maven project structure. Placing your inside src/main/resources is normal practice for resource files - as Maven will automatically transfer these to the classpath of the final artifact - which will be /WEB-INF/classes inside your war.

However, you should modify the location attribute of your <context:property-placeholder> tag and remove the resources folder prefix. The resources folder itself is not transferred to /WEB-INF/classes when the war file is built - and so won't be part of the runtime classpath. Just the folder contents are transferred.

<context:property-placeholder location="" />

Need Your Help

why there is two instances of a singleton with Google Guice dependency injection framework

java singleton guice

I am developper in a compagny using Google Guice as dependency injection framework in a MVC architecture.

Java KeyPressed KeyRelease and holding a Key

java swing keyboard keypress

I'm trying to to get my character to move left and right, and then stop when you take your fingers off of the left or right arrow keys but what keeps happening is he keeps going. Here is my keypre...