【发布时间】:2014-03-13 02:15:29
【问题描述】:
这不起作用:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:encryption="http://www.jasypt.org/schema/encryption"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.jasypt.org/schema/encryption
http://www.jasypt.org/schema/encryption/jasypt-spring31-encryption-1.xsd">
<import resource="properties/secure/jasypt-context.xml" />
<bean name="propEnvironment" class="java.lang.String">
<constructor-arg value="#{ systemProperties['property.environment'] ?: systemProperties['cfg.environment'] }" />
</bean>
<encryption:encryptable-property-placeholder
encryptor="configurationEncryptor"
location="classpath:properties/#{propEnvironment}/*.properties,classpath:properties/common.properties" />
</beans>
只有 common.properties 由可加密属性占位符配置。就像另一个条目消失了(没有抛出错误或任何东西,它只是不加载其他任何东西)。我想用生产配置文件建立一个实例,但我想使用我的开发属性。如果我将其打印出来,则 spel 表达式正在正确评估。这可能吗?
当我尝试这个时,
<bean name="propEnvironment" class="java.lang.String" id="testing">
<constructor-arg value="#{ systemProperties['property.environment'] ?: systemProperties['cfg.environment'] }" />
</bean>
<bean name="fullString" class="java.lang.String">
<constructor-arg value="classpath:properties/#{ systemProperties['property.environment'] ?: systemProperties['cfg.environment'] }/*.properties" />
</bean>
<bean class="EchoBean" lazy-init="false">
<constructor-arg ref="propEnvironment" />
</bean>
<bean class="EchoBean" lazy-init="false">
<constructor-arg ref="fullString" />
</bean>
<bean class="EchoBean" lazy-init="false">
<constructor-arg value="#{@testing.toString()}" />
</bean>
<bean class="EchoBean" lazy-init="false">
<constructor-arg value="blah" />
</bean>
使用@语法的第三个回显不产生任何输出。
2014-02-14 10:03:41,998 [main] INFO EchoBean - local
2014-02-14 10:03:42,000 [main] INFO EchoBean - classpath:properties/local/*.properties
2014-02-14 10:03:42,000 [main] INFO EchoBean - blah
【问题讨论】:
标签: java spring properties expression spring-el