无法从spring-servlet.xml创建propertyConfigurer的bean

时间:2018-08-15 20:35:20

标签: spring tomcat

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?

1 个答案:

答案 0 :(得分:0)

“:#{systemProperties.env}”的语法正确,它引用了JVM属性。我只需要添加-Denv =即可使其正常工作。