问题描述
基于 XML 方式编写 Spring 代码时,引入的 jdbc.properties 属性配置文件的 username 被神奇的替换为当前系统的用户名,例如属性配置文件里的 username 明明写的是 root,但代码运行显示 username 却是 Administrator,非常的诡异。
Spring 主配置文件中问题相关代码如下:
<context:property-placeholder location="jdbc.properties"/>
<bean id="dataSource" class="com.ltb.MyDataSource">
<property name="properties">
<props>
<prop key="driver">${driver}</prop>
<prop key="url">${url}</prop>
<prop key="username">${username}</prop>
<prop key="password">${password}</prop>
</props>
</property>
</bean>
jdbc.properties 属性配置文件代码如下:
driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://lo