简体   繁体   中英

How to configure jasypt in java spring 2.0?

I had a problem with Jasypt.. I can't configure jasypt in my program with Java Spring.

This is my configuration in jdbc.properties:

c3p0.db.driverClass = org.postgresql.Driver
c3p0.db.url = jdbc:postgresql://localhost:5432/igate-iacss
c3p0.db.user = postgres
c3p0.db.pass = ENC(5Urp3uiKn828jwkOerTslYtSSeMul0p7)
c3p0.db.initialPoolSize = 5
c3p0.db.minPoolSize = 5
c3p0.db.maxPoolSize = 20
c3p0.num.helper.thread = 5

My datasource code in xml:

<?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:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
                           http://www.springframework.org/schema/tx 
                           http://www.springframework.org/schema/tx/spring-tx-3.1.xsd            
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context-3.1.xsd"
       default-lazy-init="false">

    <!-- turn on @Resource, @PostConstruct, and @PreDestroy  -->
    <context:annotation-config />

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
        <property name="driverClass">
            <value>${c3p0.db.driverClass}</value>
        </property>
        <property name="jdbcUrl">
            <value>${c3p0.db.url}</value>
        </property>
        <property name="user">
            <value>${c3p0.db.user}</value>
        </property>
        <property name="password">
            <value>${c3p0.db.pass}</value>
        </property>
        <property name="initialPoolSize">
            <value>${c3p0.db.initialPoolSize}</value>
        </property>
        <property name="minPoolSize">
            <value>${c3p0.db.minPoolSize}</value>
        </property>
        <property name="maxPoolSize">
            <value>${c3p0.db.maxPoolSize}</value>
        </property>
        <property name="numHelperThreads">
            <value>${c3p0.num.helper.thread}</value>
        </property>
    </bean>

    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <constructor-arg ref="dataSource"/>
    </bean>

    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager" />

</beans>

How to configure that in java spring? Please help me. I hope someone can help me, just stack and can't think anymore.

Please refer to the document http://www.jasypt.org/spring3.html# for integrating spring and jasypt depends upon the spring version you use.

I've created a sample spring application with jasypt. Refer to the repo here if you are looking for an example spring-jasypt-example

You may need to add mvn dependency jasypt-mvn-dependency and integrate jasypt-spring-configuration .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM