开发者

passing command line parameter to spring config

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜