在我的 applicationcontext.xml 我有这个:
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/dashboardsupervisor" />
<property name="username" value="root" />
<property name="password" value="1234" />
</bean>
在这里,我正在连接我的数据库:
ApplicationContext ctx = new ClassPathXmlApplicationContext(
"applicationContext.xml");
MySQLRdbHelper rdbHelper = (MySQLRdbHelper)
ctx.getBean("ManagerSupervisor");
想要的是不要从我的 applicationcontext.xml 中读取密码“1234”,而是从我本地驱动器中的某些属性文件中读取它。因为这将在不同的机器上运行,并且每台机器都有不同的密码。
我能做到这一点。
谢谢