[英]Use property within application from command line (java -cp) while running jar
I am running standalone jar with below command, 我正在使用以下命令运行独立的jar,
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, 现在,我正在尝试从我的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>
But it's not working, is there any way to use my.prop
within application? 但是它不起作用,是否可以在应用程序中使用my.prop
? Please note, I don't want to use any property file for my.prop
property. 请注意,我不想为my.prop
属性使用任何属性文件。
Thanks in advance. 提前致谢。
我得到了解决方案,似乎我尝试使用错误的命令,使用以下命令
java -Dmy.prop=test1 -cp my-jar.jar my.com.Main
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.