Mybatis属性(properties)的使用

1、编写一个配置文件(db.properties)

driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/mybatis?
useSSL=false&useUnicode=true&characterEncoding=utf8
username=root
password=123456

在核心配置文件中引入

 <!--引入外部配置文件-->
    <properties resource="db.properties">
        <property name="username" value="root"/>
        <property name="password" value="123456789"/>
    </properties>
   
  • 可以直接引入外部文件
  • 可以在其中增加一些属性配置
  • 如果两个文件有同一字段,优先使用外部配置文件的!
发布了29 篇原创文章 · 获赞 49 · 访问量 1780

猜你喜欢

转载自blog.csdn.net/qq_41256881/article/details/105362762