WEB-INF / spring-servlet.xml的相关定义如下。
<bean id="propertyConfigurer"
class="org.jasypt.spring31.properties.EncryptablePropertyPlaceholderConfigurer">
<constructor-arg ref="standardEncryptor" />
<property name="locations">
<list>
<value>classpath:#{systemProperties.env} jdbc_server.properties</value>
<value>classpath:#{systemProperties.env} DBIB.properties</value>
<value>classpath:#{systemProperties.env}smtp.properties</value>
<value>classpath:#{systemProperties.env}templatedatabase.properties
</value>
<value>classpath:InstanceOrderWFEmail.properties</value>
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true" />
</bean>
看起来“ systemProperties”不是系统属性的有效引用名称。从tomcat加载应用程序时出现以下错误。
15-Aug-2018 15:53:26.599 SEVERE [http-nio-8080-exec-18] org.apache.catalina.core.ApplicationContext.log StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'propertyConfigurer' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]:
Initialization of bean failed;
nested exception is org.springframework.beans.factory.BeanExpressionException:
Expression parsing failed; nested exception is org.springframework.expression.spel.SpelEvaluationException:
EL1008E: Property or field 'env' cannot be found on object of type 'java.util.Properties' - maybe not public?
最佳答案
引用JVM属性的语法“:#{systemProperties.env}”是正确的。我只需要添加-Denv =即可使其正常工作。