1sqlMapConfig.xml
SqlMapConfig.xml The contents and order of configuration in are as follows :
properties( attribute )
settings( Global configuration parameter )
typeAliases( Type the alias )
typeHandlers( Type processor )
objectFactory( Object factory )
plugins( plug-in unit )
environments( Environment collection property object )
environment( Environment sub property object )
transactionManager( Business management )
dataSource( data source )
mappers( mapper )
.1properties Attribute definitions 
You can configure some common attribute values in the attribute file , Load into mybatis In the operating environment .
such as : establish db.properties Configure database connection parameters . This property file is referenced below .
Properties file :
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/mybatis
jdbc.username=root
jdbc.password=mysql

 Be careful : MyBatis The properties will be loaded in the following order :
 stay properties The attributes defined in the element body are first read .
<properties ><property name="" value=""/></properties>
 Then it reads properties In the elements resource or url Loaded properties , It will overwrite the read property with the same name .
<properties resource="db.properties"></properties>
 Last read parameterType(parameterType="cn.itcast.mybatis.po.User") Properties passed , It will overwrite the read property with the same name . It is recommended to use properties, Not in properties Define properties in , Only reference defined properties Properties in the file , also properties Defined in the file key There should be some special rules .
.1settings Global parameter configuration 
mybatis The runtime can adjust some global parameters ( Equivalent to the operating parameters of the software ), Reference resources :mybatis-settings.xlsx
Configure the parameters according to the requirements ( Open the cache , Delay loading, etc ).
Be careful : Careful configuration , Configuration parameters affect mybatis Implementation . ibatis The global configuration parameters of include many performance parameters ( Maximum number of threads , Maximum waiting time ...), By adjusting these performance parameters, we can make ibatis Achieve high performance operation ,mybatis Without these performance parameters , from mybatis Automatic adjustment .
.1typeAliases( Commonly used )
Can be parameterType、resultType The type specified in By alias reference .
1.1.1mybaits There are a lot of aliases 
Alias Type of mapping
_byte byte
_long long
_short short
_int int
_integer int
_double double
_float float
_boolean boolean
string String
byte Byte
long Long
short Short
int Integer(java.iang.Integer)
integer Integer
double Double
float Float
boolean Boolean
date Date
decimal BigDecimal
bigdecimal BigDecimal 1.1.2 Custom alias

 Use the alias 
stay parameterType、resultType Use aliases :

typeHandlers( Type processor )
The type processor will java The type and jdbc Type . mybatis There are many types of processors available by default , Generally enough .
1.1.1mappers
<!-- load mapper mapping 
If it will be with spring After integration , You can use the mapper Scanner , Here mappers No need to configure .
-->
<mappers>
<!-- resource yes classpath, adopt resource load mapper Map file of -->
<mapper resource="sqlmap/User.xml" />
<!-- <mapper resource="mapper/UserMapper.xml" /> -->
<!-- adopt class quote mapper Interface
class: To configure mapper The interface is fully qualified
requirement : need mapper.xml and mapper.java With the same name and in a directory in
-->
<!-- <mapper class="cn.itcast.mybatis.mapper.UserMapper"/> -->
<!-- Batch mapper To configure
adopt package Do an automatic scan of the... Under the package mapper Interface ,
requirement : need mapper.xml and mapper.java With the same name and in a directory in
This loads the mapping file .
-->
<package name="cn.itcast.mybatis.mapper"/> </mappers>

SqlMapsinfig.xml file

<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration> <!-- Attribute definitions
Load one properties file ,
It can also be in properties label Configure attribute values in
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/mybatis
jdbc.username=root
jdbc.password=mysql
-->
<properties resource="db.properties">
<!-- <property name="" value=""/> -->
</properties> <!-- Definition Alias -->
<typeAliases>
<!--
Definition of a single alias
alias: Alias ,type: The type of alias mapping -->
<!-- <typeAlias type="cn.itcast.mybatis.po.User" alias="user"/> -->
<!-- Batch alias definition
Specify the package path , Auto scan the bottom of the package pojo, Define an alias , The alias is the class name by default ( The first letter is lowercase or uppercase )
-->
<package name="cn.itcast.mybatis.po"/> </typeAliases> <!-- and spring After integration environments Configuration will be abolished -->
<environments default="development">
<environment id="development">
<!-- Use jdbc Business management -->
<transactionManager type="JDBC" />
<!-- Database connection pool -->
<dataSource type="POOLED">
<!-- Database connection parameters -->
<property name="driver" value="${jdbc.driver}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</dataSource>
</environment>
</environments> <!-- load mapper mapping
If it will be with spring After integration , You can use the mapper Scanner , Here mappers No need to configure .
-->
<mappers>
<!-- resource yes classpath, adopt resource load mapper Map file of -->
<mapper resource="sqlmap/User.xml" />
<!-- <mapper resource="mapper/UserMapper.xml" /> -->
<!-- adopt class quote mapper Interface
class: To configure mapper The interface is fully qualified
requirement : need mapper.xml and mapper.java With the same name and in a directory in
-->
<!-- <mapper class="cn.itcast.mybatis.mapper.UserMapper"/> -->
<!-- Batch mapper To configure
adopt package Do an automatic scan of the... Under the package mapper Interface ,
requirement : need mapper.xml and mapper.java With the same name and in a directory in
This loads the mapping file .
-->
<package name="cn.itcast.mybatis.mapper"/> </mappers> </configuration>

mybatis11 sqlMapConfig.xml More related articles on documentation

  1. JAVAEE——Mybatis The first day : introduction 、jdbc The problem is 、 Architecture introduction 、 Entry procedure 、Dao Development method of 、 Dynamic proxy mode of interface 、SqlMapConfig.xml The document states

    1. Study plan The first day : 1.Mybatis Introduction to 2.Mybatis To get started a)  Use jdbc Problems in operating the database b) Mybatis The architecture of c) Mybatis How to get started with 3.Dao Development method of ...

  2. 【MyBatis Study 05】SqlMapConfig.xml The configuration summary in the file

    After the summary of the last two blog articles , Yes mybatis Medium dao Development methods and processes are basically mastered , This section mainly summarizes mybatis Global profile in SqlMapConfig.xml Some common configurations in development , Let's first look at the global configuration ...

  3. Mybatis Learning record ( 3、 ... and )---- understand SqlMapConfig.xml file

    SqlMapConfig.xml mybatis Global configuration file for SqlMapConfig.xml, The configuration is as follows : properties( attribute ) settings( Global configuration parameter ) typeAliases( ...

  4. understand SqlMapConfig.xml file

    SqlMapConfig.xml mybatis Global configuration file for SqlMapConfig.xml, The configuration is as follows : properties( attribute ) settings( Global configuration parameter ) typeAliases( ...

  5. Mybatis Journey 3 -SqlMapConfig.xml Global profile resolution

    One . Preface Just changed jobs , For a faster learning framework and understanding of the business , Basically work overtime every day , Lead to a few days without a summary , I always feel uneasy , The longer you work, the more important you feel about learning , Hold the line !!! After the summary of the first two articles , I have basically mastered mybat ...

  6. mybatis Exception resolution :class path resource [SqlMapConfig.xml] cannot be opened because it does not exist

    resolvent : defect SqlMapConfig.xml file .

  7. Mybatis Learning summary ( 3、 ... and )——SqlMapConfig.xml Global profile resolution

    After the summary of the last two blog articles , Yes mybatis Medium dao Development methods and processes are basically mastered , This section mainly summarizes mybatis Global profile in SqlMapConfig.xml Some common configurations in development , Let's first look at the global configuration ...

  8. SqlMapConfig.xml In the configuration file properties attribute

    1. The original SqlMapConfig.xml The content of the configuration file is : <?xml version="1.0" encoding="UTF-8" ?> < ...

  9. Mybatis( Two )--SqlMapConfig.xml The configuration file

    One . brief introduction SqlMapConfig.xml yes Mybatis Global configuration file for , We're writing mybatis Project time , stay SqlMapConfig.xml The database data source is mainly configured in the file . Business . Mapping files, etc , In fact, there are a lot of matches ...

Random recommendation

  1. python ldap

    # -*- coding: UTF-8 -*- import ldap, ConfigParser, os from ldap import modlist LDAP_HOST = "myd ...

  2. web Front end HTML The big frame of (body Elements and frameset Elements )

    web Front end HTML The big frame of      body Elements and frameset Elements For those engaged in html For the people in charge , The framework we are familiar with is to declare html , And then in <html> The label is wrapped in <head ...

  3. systemctl replace service

    To use systemd, linux The kernel version is higher : 2.6.39 systemctl Command format for : systemctl Action command ( Such as start stop restart status) The service name .ser ...

  4. use mciSendString Making music players

    Music operation class public class clsMCI { public clsMCI() { // // TODO: Add constructor logic here // } // Definition API The string variable used by the function [Marsha ...

  5. Mongodb shell Basic operation

    /opt/mongodb-2.6.6/bin > mongo 1. Query all local database names > show dbs 2. Switch to the specified database environment ( If there is no specified database , Create a new library )> use ...

  6. High performance WEB Development of Web Performance testing tools recommended

    Firebug: Firebug yes firefox The most classic development tool in , You can monitor the request header , Response head , Show resource loading waterfall : HttpWatch: httpwatch The function is similar to firebug, You can monitor the request header , ...

  7. PowerDesigner Set up null constraint

    stay PDM The last... Of each row in the field list of the table properties of P,F,M Medium M(Mandatory) Just tick it , So in the generation of SQL Will become not NULL Mandatory: Compulsive , I don't know if it can be understood that it must be assigned

  8. (10) process ---Manager Data sharing

    Manager  It can realize data sharing between processes (dict list), But it has to be locked to ensure the accuracy of the data , Queue can realize data communication between processes from multiprocessing import Proce ...

  9. Java Type Inference ( Type inference )

    public class Test2 { public static void main(String[] args) { ArrayList<String> list = newArra ...

  10. Hive The function of learning DDL and Show、Describe sentence

    establish / Delete function Create temporary functions The following statement is created by class_name Temporary functions implemented , This function can only be used in the current session after it is created . The function fails at the end of the session . The class that implements the function can be Hive Random classes in the classpath . Able to use Ad ...