Announcement Announcement Module
Collapse
No announcement yet.
Property Override not Working in Jar File Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Property Override not Working in Jar File

    Here's my setup:

    newsletter-service.xml (located in jar):

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    		
    	<bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
        	<property name="propertySources">
            	<list>
               		<value>classpath:properties/newsletter.dev.properties</value>
            	</list>
        	</property>
    	</bean>
    
    	<bean name='apiKey' class='java.lang.String' autowire="byName">
    		<constructor-arg value='${api.key}' />
    	</bean>
     . . .
    properties/newsletter.dev.properties (also in jar)
    Code:
    api.key=blah,blah
    access.token=something
    master.list.id=141
    When I start oin Tomcat, I get

    Code:
    org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'apiKey' defined in URL [jar:file:/C:/Documents%20and%20Settings/jr/.m2/repository/org/tabbysplace/newsletter/newsletter/1.22.0/newsletter-1.22.0.jar!/spring/newsletter-service.xml]: Could not resolve placeholder 'api.key' in string value "${api.key}"
    By all evidence, the properties file is not getting loaded. In fact, it appears as if the PropertySourcesPlaceholderConfigurer is not being invoked. If I change the properties file name to something like

    Code:
    blah.dev.garbage
    The result is the same. I have tired:
    1) Using

    Code:
    <context:property-placeholder
    		location="classpath:properties/newsletter.${spring.profiles.active}.properties" />
    Result is the same

    2) Subclassing PropertySourcesPlaceholderConfigurer & adding debug output. No methods are invokmed.

    I'm at a loss. Any ideas?

  • #2
    The bean name and class details need to be specified in double quotes (").

    <bean name="apiKey" class="java.lang.String" autowire="byName">
    <constructor-arg value='${api.key}' />
    </bean>

    Comment


    • #3
      Huh?

      Originally posted by manjunatha.hiremath View Post
      The bean name and class details need to be specified in double quotes (").
      Not a chance this is correct. The file is XML.

      Comment

      Working...
      X