使用spring配置文件读取现有属性

使用spring配置文件读取现有属性,spring,spring-3,Spring,Spring 3,要阅读弹簧配置文件,我使用: <beans profile="LOC"> 我想改用已配置的现有属性: -Dmyproperty=LOC 我是否可以使用spring配置文件来使用现有属性(myproperty)而不是spring.profiles.active?查看类。系统属性名称在此处硬编码: /** * Name of property to set to specify active profiles: {@value}. Value may be comma

要阅读弹簧配置文件,我使用:

<beans profile="LOC">
我想改用已配置的现有属性:

-Dmyproperty=LOC
我是否可以使用spring配置文件来使用现有属性(
myproperty
)而不是
spring.profiles.active

查看类。系统属性名称在此处硬编码:

   /**
     * Name of property to set to specify active profiles: {@value}. Value may be comma
     * delimited.
     * <p>Note that certain shell environments such as Bash disallow the use of the period
     * character in variable names. Assuming that Spring's {@link SystemEnvironmentPropertySource}
     * is in use, this property may be specified as an environment variable as
     * {@code SPRING_PROFILES_ACTIVE}.
     * @see ConfigurableEnvironment#setActiveProfiles
     */
    public static final String ACTIVE_PROFILES_PROPERTY_NAME = "spring.profiles.active";
/**
*要设置以指定活动配置文件的属性名称:{@value}。值可以是逗号
*分隔。
*注意,某些shell环境(如Bash)不允许使用句点
*变量名中的字符。假设Spring的{@link SystemEnvironmentPropertySource}
*在使用中,此属性可以指定为环境变量,如下所示:
*{@code-SPRING\u-PROFILES\u-ACTIVE}。
*@请参阅ConfigurableEnvironment#setActiveProfiles
*/
public static final String ACTIVE\u PROFILES\u PROPERTY\u NAME=“spring.PROFILES.ACTIVE”;
所以,是的,你可以破解它并将其更改为你的属性名称,或者使其可配置并重新编译你自己的版本(孩子们请不要在家里尝试)。系统属性名称在此处硬编码:

   /**
     * Name of property to set to specify active profiles: {@value}. Value may be comma
     * delimited.
     * <p>Note that certain shell environments such as Bash disallow the use of the period
     * character in variable names. Assuming that Spring's {@link SystemEnvironmentPropertySource}
     * is in use, this property may be specified as an environment variable as
     * {@code SPRING_PROFILES_ACTIVE}.
     * @see ConfigurableEnvironment#setActiveProfiles
     */
    public static final String ACTIVE_PROFILES_PROPERTY_NAME = "spring.profiles.active";
/**
*要设置以指定活动配置文件的属性名称:{@value}。值可以是逗号
*分隔。
*注意,某些shell环境(如Bash)不允许使用句点
*变量名中的字符。假设Spring的{@link SystemEnvironmentPropertySource}
*在使用中,此属性可以指定为环境变量,如下所示:
*{@code-SPRING\u-PROFILES\u-ACTIVE}。
*@请参阅ConfigurableEnvironment#setActiveProfiles
*/
public static final String ACTIVE\u PROFILES\u PROPERTY\u NAME=“spring.PROFILES.ACTIVE”;
所以,是的,你可以破解它并将其更改为你的财产名称,或者使其可配置并重新编译你自己的版本(孩子们请不要在家里尝试)