blob: 076c9579a4c9caa8c18e0214bbe388e67732931d [file] [log] [blame]
<?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:tx="http://www.springframework.org/schema/tx"
xmlns:bean="http://www.springframework.org/schema/util"
xmlns:encrypt="http://shardingsphere.apache.org/schema/shardingsphere/encrypt"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://shardingsphere.apache.org/schema/shardingsphere/encrypt
http://shardingsphere.apache.org/schema/shardingsphere/encrypt/encrypt.xsd">
<context:component-scan base-package="org.apache.shardingsphere.example.core.mybatis" />
<bean id="demo_ds" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_ds?useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>
<property name="username" value="root"/>
<property name="password" value=""/>
</bean>
<bean:properties id="props">
<prop key="aes.key.value">123456</prop>
</bean:properties>
<encrypt:data-source id="encryptDataSource" data-source-name="demo_ds" >
<encrypt:encrypt-rule>
<encrypt:tables>
<encrypt:table name="t_user">
<encrypt:column logic-column="user_name" plain-column="user_name" cipher-column="user_name_cipher" encryptor-ref="encryptor_md5" />
<encrypt:column logic-column="pwd" plain-column="pwd_plain" cipher-column="pwd_cipher" encryptor-ref="encryptor_md5"/>
</encrypt:table>
</encrypt:tables>
<encrypt:encryptors>
<encrypt:encryptor id="encryptor_aes" type="AES" props-ref="props"/>
<encrypt:encryptor id="encryptor_md5" type="MD5" />
</encrypt:encryptors>
</encrypt:encrypt-rule>
<encrypt:props>
<prop key="sql.show">false</prop>
</encrypt:props>
</encrypt:data-source>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="encryptDataSource"/>
<property name="mapperLocations" value="classpath*:META-INF/mappers/mysql/*.xml"/>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="org.apache.shardingsphere.example.core.mybatis.repository"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
</beans>