MyBatis XML configuration

Attribute parameters

<properties resource="org/mybatis/example/config.properties">
  <property name="username" value="dev_user"/>
  <property name="password" value="F2Fa3!33TYyg"/>
</properties>

The above embodiment defined parameters are used in XML as "variable" in the configuration file, using methods such as ${username}
may be used ${username:ut_user}as a parameter to set the default value, wherein the default value ut_user as username when not defined username, which value is the default value.
The default is the default value is not available, use the following parameters to open

<property name="org.apache.ibatis.parsing.PropertyParser.enable-default-value" value="true"/> <!-- 启用默认值特性 -->
  <property name="org.apache.ibatis.parsing.PropertyParser.default-value-separator" value="?:"/> <!-- 修改默认值的分隔符为?: -->

Properties load order

In vivo properties specified properties element are read first.
Then reads the property file according to the attribute file attribute properties resource elements to read the class path or paths specified by the url attribute, and covering the same name attribute is read.
Finally, a method to read the property passed as parameters, and covering the same name attribute is read.

Guess you like

Origin www.cnblogs.com/CoveredWithDust/p/MyBatis_XML.html