xml中读取properties文件

  1. 在Resource文件夹中创建配置database.properties文件
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/ims?useUnicode=true&characterEncoding=utf-8
user=root
password=xxxxxx
  1. 在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
猜你喜欢
  • 2022-02-04
  • 2021-07-23
  • 2021-07-03
  • 2021-05-22
  • 2022-12-23
  • 2021-10-11
  • 2021-08-18
相关资源
相似解决方案