简介 #
DBPlusEngine-Driver 提供 JDBC 驱动,开发者可以在 Spring 中配置 SphereExDriver 来使用 DBPlusEngine-Driver。
使用步骤 #
引入 Maven 依赖 #
<dependency>
<groupId>com.sphere-ex</groupId>
<artifactId>dbplusengine-driver-all-in-one</artifactId>
<version>${dbplusengine.version}</version>
</dependency>
配置 Spring Bean #
配置项说明 #
| 名称 | 类型 | 说明 |
|---|---|---|
| driverClass | 属性 | 数据库 Driver,这里需要指定使用 SphereExDriver |
| url | 属性 | YAML 配置文件路径 |
配置示例 #
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="shardingDataSource" class="com.zaxxer.hikari.HikariDataSource">
<property name="driverClass" value="com.sphereex.dbplusengine.driver.SphereExDriver" />
<property name="url" value="jdbc:sphereex:classpath:xxx.yaml" />
</bean>
</beans>
使用数据源 #
使用方式同 Spring Boot。