java - Subsets of Properties With Spring -
suppose have properties file contents looking this:
local.jndi.datasource = localdatasource dev.jndi.datasource = devdatasource test.jndi.datasource = testdatasource prod.jndi.datasource = proddatasource
i have scheme variables called "app.configdir" , "app.environment". app.environment variable can "local","dev","test", or "prod".
what this:
<context:property-placeholder location="file:#{systemproperties['app.configdir'] }/>
however, have properties narrowed downwards subset defined in environment variable.
is there relatively easy way in xml configuration? can think of couple of ways if able utilize programatic configuration.
edit: using spring 3.1.
you should able utilize spring profiles of spring 3.1. in config can have multiple , place
<beans profile="local"> <context:property-placeholder order="1" location="classpath*:meta-inf/spring/some.properties"/> </beans> <beans profile="dev"> <context:property-placeholder order="1" location="classpath*:meta-inf/spring/someother.properties"/> </beans>
see next link total illustration on using spring profiles: http://java.dzone.com/articles/using-spring-profiles-xml
java spring
No comments:
Post a Comment