Tag: environment variables

PropertyPlaceholderConfigurer和.properties文件中的环境变量

我有一个带有PropertyPlaceholderConfigurer的Spring application-context.xml,用于从.properties文件中获取属性值。 主文件夹和测试源文件夹具有单独的.properties文件。 问题是我需要在.properties文件中使用环境变量。 但是,当我按以下方式执行此操作时: property.name=${env.SYSTEM_PROPERTY} 我收到以下错误: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name ‘beanName’ defined in class path resource [com/example/applicationContext.xml]: Could not resolve placeholder ‘env.SYSTEM_PROPERTY’ 而占位符配置器定义为 任何想法如何使property.name被解释为环境变量(而不是占位符)? 最好的问候,德米特里。