我使用Spring和MyBatis连接到Oracle数据库。我有jdbc.properties
我在其中存储数据库的用户名和密码。
我使用以下spring配置连接到oracle数据库。
<?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:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
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/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
<context:annotation-config />
<beans profile="mybatis">
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="serverManagedDataSource" />
<!-- <property name="dataSource" ref="dataSource" /> -->
<property name="mapperLocations" value="classpath*:mappers/**/*.xml" />
</bean>
<context:property-placeholder location="classpath:jdbc.properties" />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="${url}" />
<property name="username" value="${username}" />
<property name="password" value="${password}" />
</bean>
在属性文件中,我使用纯文本格式的密码。由于将密码存储在纯文本中不是一个好主意,因此我计划在属性文件中存储加密密码。如果我加密密码,我该如何解密它并将其映射到弹簧配置中的{{password}}
字段。请告诉我。