Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用spring加载基于java参数的动态属性文件_Spring - Fatal编程技术网

如何使用spring加载基于java参数的动态属性文件

如何使用spring加载基于java参数的动态属性文件,spring,Spring,我正在使用Spring3.2。我有不同的属性文件,如a.properties、b.properties、c.properties。现在,在我的春天,我使用的是 public class FtpInbound { private static final String XML_CONFIG_FILE_LOCATION = "springIntegration/ftp-inbound-context.xml"; public static void main(String[] a

我正在使用Spring3.2。我有不同的属性文件,如
a.properties、b.properties、c.properties
。现在,在我的春天,我使用的是

public class FtpInbound {

    private static final String XML_CONFIG_FILE_LOCATION = "springIntegration/ftp-inbound-context.xml";

    public static void main(String[] args) {

        GenericXmlApplicationContext context = new GenericXmlApplicationContext();
        context.load(XML_CONFIG_FILE_LOCATION);
        context.refresh();

    } //end of main()

} //end of class Main
在xml中,我使用的是

<context:property-placeholder location="/spring/ftp/ftp.properties"/>

<context:component-scan base-package="pk.training.basitMahmood.springIntegration.ftp"/>

现在我想知道,如果用户将作为参数传递给main()方法,那么它将成为

<context:property-placeholder location="/spring/ftp/a.properties"/>

若用户将b传递给main()参数,则它将变为

<context:property-placeholder location="/spring/ftp/b.properties"/>

等等

我怎么做


谢谢

可以使用环境变量吗?e、 g.正如在这一问题上: