2017-05-29 186 views
0

我們正在將基於ant的spring 3.1應用程序遷移到基於maven的spring 4.3.8。我們正在用Jasypt 1.9.2加密我們的屬性文件條目。然而,當應用程序啓動時,它拋出在WEB-INF/lib文件夾Jasypt 1.9.2是否與Spring 4.3.8兼容?

Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.jasypt.spring31.properties.EncryptablePropertyPlaceholderConfigurer] for bean with name 'propertyPlaceholderConfigurer' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.jasypt.spring31.properties.EncryptablePropertyPlaceholderConfigurer 

jasypt-1.9.2和jasypt-spring31-1.9.2罐可用。下面是應用程序上下文:

<?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:context="http://www.springframework.org/schema/context" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:aop="http://www.springframework.org/schema/aop" 
    xsi:schemaLocation=" 
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd 
     http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd 
     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> 

    <mvc:annotation-driven /> 
    <mvc:resources mapping="*.html" location="/" /> 

    <context:component-scan base-package="com.xyz" /> 
    <bean id="propertyPlaceholderConfigurer" 
     class="org.jasypt.spring31.properties.EncryptablePropertyPlaceholderConfigurer"> 
     <constructor-arg ref="configurationEncryptor" /> 
    </bean> 

    <bean id="configurationEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor"> 
     <property name="config" ref="environmentVariablesConfiguration" /> 
    </bean> 

    <bean id="environmentVariablesConfiguration" 
     class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig"> 
     <property name="algorithm" value="PBEWithMD5AndDES" /> 
     <property name="password" value="xxxx" /> 
    </bean> 
</beans> 

Maven的條目是:

<dependency> 
     <groupId>org.jasypt</groupId> 
     <artifactId>jasypt-spring31</artifactId> 
     <version>1.9.2</version> 
</dependency> 

回答

0

號根據http://jasypt.org/encrypting-configuration.html

Spring的集成的.properties文件透明解密:Jasypt可以融入配置Spring框架系統(2.x和3.x)並透明地解密Spring應用程序使用的.properties文件。瞭解更多信息:Spring 2.x,Spring 3.0,Spring 3.1。