0

I am running standalone jar with below command,

java -cp my-jar.jar my.com.Main -Dmy.prop=test1

Now, I am trying to resolve my.prop from my spring config like below,

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="properties">
        <util:properties>
            <prop key="my.second.property">${my.prop}-something</prop>
        </util:properties>
    </property>
</bean>

But it's not working, is there any way to use my.prop within application? Please note, I don't want to use any property file for my.prop property.

Thanks in advance.

Vishal Zanzrukia
  • 4,902
  • 4
  • 38
  • 82
  • Did you try with systemProperties? Please see http://stackoverflow.com/questions/3965446/how-to-read-system-environment-variable-in-spring-applicationcontext – OTM May 01 '17 at 07:28

1 Answers1

0

I got my solution, it seems I was trying with wrong command, working with below command

java -Dmy.prop=test1 -cp my-jar.jar my.com.Main

Vishal Zanzrukia
  • 4,902
  • 4
  • 38
  • 82