5
コマンドラインパラメータとして渡されるプロパティファイルで初期化されたスプリングコマンドラインプログラムを作成したいと思います。それはどうやってできますか?コマンドラインからスプリングコンテキストのプロパティをロード
開始クラス:
public static void main (String [] args) {
String configFilename = args[0];
ApplicationContext ctx = new ClassPathXmlApplicationContext(
"classpath:/context/applicationContext.xml");
MyBean bean = ctx.getBean(MyBean.class);
bean.getStarted();
}
applicationContext.xmlを:私は正しいをロードできるように、私は、実際の春のコンテキストに私のメインメソッドから設定ファイル名を乗り越えるにはどうすればよい
<context:property-placeholder location="CONFIGFILENAME" ignore-unresolvable="true"/>
環境依存のプロパティ?あなたのケースでは
代わりにJVM引数を使用できます。 http://stackoverflow.com/questions/5598217/how-do-i-read-jvm-arguments-in-the-spring-applicationcontext-xml – DB5