-
Notifications
You must be signed in to change notification settings - Fork 15
XMLConfigFile
GangCheng edited this page Jan 20, 2024
·
2 revisions
-
Explanation:
<configuration> <properties resource="mybatis-config.properties"> <!--keep the original behavior of mybatis3 --> <!-- other properties--> <!-- <property name="" value=""/> --> </properties> <settings> <!--keep the original behavior of mybatis3 --> <setting name="mapUnderscoreToCamelCase" value="true"/> </settings> <typeAliases> <!--keep the original behavior of mybatis3 --> <typeAlias alias="Dept" type="pro.chenggang.project.reactive.mybatis.support.common.entity.Dept"/> <typeAlias alias="Emp" type="pro.chenggang.project.reactive.mybatis.support.common.entity.Emp"/> <typeAlias alias="Subject" type="pro.chenggang.project.reactive.mybatis.support.common.entity.Subject"/> <typeAlias alias="SubjectContent" type="pro.chenggang.project.reactive.mybatis.support.common.entity.SubjectContent"/> <typeAlias alias="SubjectData" type="pro.chenggang.project.reactive.mybatis.support.common.entity.SubjectData"/> </typeAliases> <environments default="r2dbc-test"> <environment id="mysql"> <!--keep the original behavior of mybatis3 for load matched the specific environment --> <!-- this node won't be used, but you need to configure it with any content for disable the original xml verification --> <transactionManager type="NOT_USED" /> <!-- if type is configured with "POOLED" then mybatis-r2dbc would wrap the ConnectionFactory with ConnectionPool by using below configure properties name as "pool.xxx" --> <dataSource type="POOLED"> <!--connection pool configuration--> <property name="pool.name" value="mysql-connection-pool" /> <property name="pool.maxSize" value="16" /> <property name="pool.initialSize" value="4" /> <property name="pool.maxIdleTime" value="PT1M" /> <property name="pool.acquireRetry" value="1" /> <property name="pool.backgroundEvictionInterval" value="-PT1S" /> <property name="pool.maxAcquireTime" value="PT-1S" /> <property name="pool.maxCreateConnectionTime" value="PT-1S" /> <property name="pool.maxLifeTime" value="PT-1S" /> <property name="pool.validationDepth" value="REMOTE" /> <property name="pool.validationQuery" value="SELECT 1" /> <!-- this property is used to customize ConnectionFactoryOptions with ConnectionFactoryOptionsConfigurer --> <!-- pro.chenggang.project.reactive.mybatis.support.r2dbc.binding.ConnectionFactoryOptionsConfigurer --> <property name="pool.configurer" value="${mysql.pool.configurer}" /> <!--connection factory configuration--> <property name="driver" value="${mysql.driver}"/> <property name="host" value="${mysql.host}"/> <property name="port" value="${mysql.port}"/> <property name="user" value="${mysql.user}"/> <property name="password" value="${mysql.password}"/> <property name="database" value="${mysql.database}"/> <!-- this property is used to customize ConnectionPool with ConnectionPoolConfigurationConfigurer --> <!-- pro.chenggang.project.reactive.mybatis.support.r2dbc.binding.ConnectionPoolConfigurationConfigurer --> <property name="@configurer" value="${mysql.configurer}"/> <!-- this property is used to automatic manage the transaction behaviour , default is true --> <!-- if this property is configured as false , then you should manage transaction and resource release manually (NOT RECOMMENDED) --> <property name="@defaultTransactionProxy" value="false"/> </dataSource> </environment> <environment id="postgresql"> <transactionManager type="UNPOOLED" /> <dataSource type="NOT_USED"> <property name="driver" value="${postgresql.driver}"/> <property name="host" value="${postgresql.host}"/> <property name="port" value="${postgresql.port}"/> <property name="user" value="${postgresql.user}"/> <property name="password" value="${postgresql.password}"/> <property name="database" value="${postgresql.database}"/> <property name="@configurer" value="${postgresql.configurer}"/> <property name="@defaultTransactionProxy" value="true"/> </dataSource> </environment> </environments> <databaseIdProvider type="DB_VENDOR"> <!--keep the original behavior of mybatis3 --> <!-- this would use R2dbcVendorDatabaseIdProvider as default --> <property name="MySQL" value="mysql"/> <property name="MariaDB" value="mariadb"/> <property name="PostgreSQL" value="postgresql"/> <property name="Microsoft SQL Server" value="mssql"/> <property name="Oracle Database" value="oracle"/> </databaseIdProvider> <mappers> <!--keep the original behavior of mybatis3 --> <mapper resource="pro/chenggang/project/reactive/mybatis/support/common/DeptMapper.xml"/> <mapper resource="pro/chenggang/project/reactive/mybatis/support/common/EmpMapper.xml"/> <mapper resource="pro/chenggang/project/reactive/mybatis/support/common/SubjectMapper.xml"/> <mapper resource="pro/chenggang/project/reactive/mybatis/support/common/SubjectDataMapper.xml"/> </mappers> </configuration>
-
Parse XML Config File
- Code sample:
R2dbcXMLConfigBuilder r2dbcXMLConfigBuilder = new R2dbcXMLConfigBuilder(inputStream,"mysql",setupProperties); R2dbcMybatisConfiguration r2dbcMybatisConfiguration = r2dbcXMLConfigBuilder.parse();
- Associated Concept
- Basic Operation Instruction
- Integration with Spring Framework