开发者

spring configuration with system property

I have a question. Currently i start jboss with -P property that links to file with properties. In this property file i have property - mongo.server.list=127.0.0.1. In Spring configuration i try to set this property as value of constructor of bean. But spring treat ${mongo.server.list} as value itself.

Here is the code

<bean id="systemPropertyConfigurer"
   class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
</bean>

<bean id="mongo" class="com.mongodb.Mongo">
    <constructor-arg index="0">
        <value>${mongo.server开发者_运维百科.list}</value>
    </constructor-arg>
</bean>


You should set your property file as a JVM property and read it in spring mvc configuration file as:

<context:property-placeholder location="file:///${-P}" />


You should specify the property as a JVM arg as -Dmongo.server.list=....


Did you try to start your server using -Dmongo.server.list=127.0.0.1 ? (i.e. using -D instead of -P, and no space between -D and the property name)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜