The content and configuration order of the SqlMapConfig.xml configuration file are as follows
properties(properties)
settings(global configuration parameters)
typeAiases (type alias)
typeHandlers (type processor)
objectFactory (Object Factory)
plugins (plugin)
environments (environment collection attribute object) mappers (mapper)
environment(environment child attribute object)
transactionManager (Trade Management)
datesource(data source
mappers(mapper)
1. SqlMapConfig.xml
1. Properties
When getting started, extract the properties file from the properties that connect to the database.
a. You can obtain properties through resource and url.
Properties can also be defined in b.properties. But it is not recommended to use
c.mybatis attribute loading order
property-----à resource/url---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2. Settings
Global parameter configuration. For example, turn on Level 2 cache and turn on delayed loading.
3. typeAliases (alias)
The input parameters and output parameters of the statement are fully qualified. Not conducive to writing.
a. Default aliases
Basic data types and Strings for java. Basic data type objects, Date, etc. have been defined
b. Define a single SqlMapConfig.xml
UserMapper.xml
c. Batch definition
The alias for the package tag is the class name (both upper and lower case is OK)
-----------------------------------------
4. typeHandlers (type converter)
Mybatis already has some default definitions. There is basically no need to define it.
Lenovo: beanutils-àString to basic data types Other data types have defaults and can also be customized.
5 environments
Mybatis environment, only using mybatis requires configuration. Abolished after integration with spring.
6.mappers
Map files. Resource has been used to load before. Mapper can be loaded through resource, url and class.
class method
The mapper interface name is the same as the mapping file. Such as UserMapper.java and UserMapper.xml
Put it in the same directory.
SqlMapConfig configuration
Batch loading (like aliased batch)
Prerequisite, the naming and placement rules of the class method. sqlmapconfig is as follows.
The above is the MyBatis SqlMapConfig.xml configuration 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!