xml中读取properties文件
- 在Resource文件夹中创建配置database.properties文件
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/ims?useUnicode=true&characterEncoding=utf-8
user=root
password=xxxxxx
- 在application.xml中配置读取文件
<!-- 1、配置数据源 -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:database.properties</value>
</property>
</bean>
<bean >
<property name="driverClassName" value="${driver}"/>
<property name="url" value="${url}"/>
<property name="username" value="${user}"/>
<property name="password" value="${password}"/>
</bean>
相关文章:
-
2021-12-13
-
2021-11-19
-
2021-05-29
-
2021-09-14
-
2021-09-30
-
2022-01-09
-
2021-06-28
-
2021-09-13