Skip to main content

dawdler-client-plug-db

Module Introduction​

Web-side transaction module, providing a transaction manager and a transaction usage essentially consistent with spring, and supporting read/write splitting. (It generally does not need to be referenced separately; it is referenced as a dependency by the mybatis or dao modules.)

1. Add the dependency to pom​

<groupId>club.dawdler</groupId>
<artifactId>dawdler-client-plug-db</artifactId>

2. web-conf.xml transaction configuration file description​

web-conf.xml is the core configuration file on the web side. It includes component scanning, configuration data source definitions, binding data sources to specified target packages, read/write splitting configuration, and health checks.

The transaction-related configuration in this module is as follows:

<datasource-expressions>
<datasource-expression id="order-datasource"
latent-expression="write=[user_writeDataSource],read=[user_readDataSource|user_readDataSource1]" /><!--
Data source expression configuration; id is the identifier and latent_expression is the read/write configuration, where write is the write connection and read is the read connection. Multiple read connections can be configured separated by |
and are called in round-robin fashion -->
</datasource-expressions>
<decisions>
<!-- mapping: the service package that needs the data source injected; latent-expression: the id in the data source expression configuration -->
<decision mapping="com.dawdler.order.service.impl"
latent-expression-id="order-datasource" />
</decisions>