1. Register the DB connection four-factor attribute file
<propertiesresource="jdbc.properties"/>
2. Treat the simple class names of all classes in the specified package as their alias
<typeAliases> <packagename="com.bjpowernode.beans"/></typeAliases>
3. Configure the operating environment
<environmentsdefault="testEM"> <environmentid="testEM"> <transactionManagertype="JDBC"/> <dataSourcetype="POOLED"> <propertyname="driver" value="${jdbc.driver}"/> <propertyname="url" value="${jdbc.url}"/> <propertyname="username" value="${jdbc.user}"/> <propertyname="password" value="${jdbc.password}"/> </dataSource> </environment> </environments>Note: Different database links can be placed in environments, default specifies which one to use, making it more convenient to modify the database
transactionManager: Specify thing management, here JDBC's thing management
dataSource: Specify the data source, and use the database connection pool here
property: put the four elements required for linking the database, driver, url, username, password;
4. Register the mapping file
<mappers> <mapperresource="com/bjpowernode/dao/mapper.xml"/></mappers>
Note: resource specifies which mapping file to register
Summarize
The above is a detailed introduction to the mybatis configuration file in the MyBatis framework introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to Wulin.com website!