开发者

passing command line parameter to spring config

开发者 https://www.devze.com 2023-04-08 10:26 出处:网络
I want to laod the spring context file based on the command line. Basically I am going to get the region from the command line and开发者_Python百科 instanciate the beans in the context file based on r

I want to laod the spring context file based on the command line. Basically I am going to get the region from the command line and开发者_Python百科 instanciate the beans in the context file based on region. Is there a way to pass the command line param to FileSystemXmlApplicationContext without maintaining 2 different context files?

Thanks in advance.


Yes, it depends on where exactly you want to load it:

  • use <import resource="${command.line.param}/context.xml" /> in your common applicationContext.xml
  • use <param-value>${command.line.param}/applicationContext.xml</param-value> in your web.xml, in a context-param named contextConfigLocation
0

精彩评论

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

关注公众号