JAVA framework Mybaits core configuration

One: the core configuration file of mybaits: SqlMapConfig.xml

Properties to be concerned about in the configuration file:

1) properties attribute: generally refer to the configuration file (properites file) such as: the configuration of the database. We can write a db.properites file. By loading the SqlMapConfig.xml file, the resource value in the properties property is preferentially read to read the configuration content of properties, and the properties and property values ​​are loaded into memory, which will overwrite the previously loaded properties of the same name.

db.properites

1 jdbc.driver=com.mysql.jdbc.Driver
2 jdbc.url=jdbc:mysql://localhost:3306/day_spring?characterEncoding=utf-8
3 jdbc.username=root
4 jdbc.password=root

properites tag:

1 <properties resource="db.properites" />

SqlMapConfig.xml supports el expressions: avoid hard coding of configuration information.

1           <dataSource type="POOLED">
2                 <property name="driver" value="${jdbc.driver}" />
3                 <property name="url" value="${jdbc.url}" />
4                 <property name="username" value="${jdbc.username}" />
5                 <property name="password" value="${jdbc.password}" />
6             </dataSource>

 2) typeAliases type aliases:

 1 别名       映射的类型
 2 _byte         byte 
 3 _long         long 
 4 _short         short 
 5 _int         int 
 6 _integer     int 
 7 _double     double 
 8 _float     float 
 9 _boolean     boolean 
10 string     String 
11 byte         Byte 
12 long         Long 
13 short     Short 
14 int         Integer 
15 integer     Integer 
16 double     Double 
17 float         Float 
18 boolean     Boolean 
19 date         Date 
20 decimal     BigDecimal 
21 bigdecimal BigDecimal 
22 map        Map

 

u  It will overwrite the read property of the same name.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324775985&siteId=291194637