2017-05-01 49 views
0

我運行獨立的罐子下面的命令,財產,同時運行的jar

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

現在,我想從我的Spring配置解決my.prop像下面,

<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> 

但它不工作,有沒有什麼辦法在應用程序內使用my.prop?請注意,我不希望使用任何屬性文件my.prop財產。

在此先感謝。

+0

你嘗試用systemProperties工作?請參閱http://stackoverflow.com/questions/3965446/how-to-read-system-environment-variable-in-spring-applicationcontext – OTM

回答

0

我得到了我的解決方案,看來我是用錯了命令嘗試,下面命令

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