Logo
Spring Namespace

Overview #

DBPlusEngine-Driver provides a JDBC driver. To use DBPlusEngine-Driver, developers can configure ShardingSphereDriver in Spring.

Operation #

Import Maven Dependency #

<dependency>
    <groupId>com.sphere-ex</groupId>
    <artifactId>shardingsphere-jdbc-core</artifactId>
    <version>${shardingsphere.version}</version>
</dependency>

Configure Spring Bean #

Configuration Item Explanation #

NameTypeDescription
driverClassAttributeDatabase Driver, need to use ShardingSphereDriver
urlAttributeYAML configuration file path

Example #

<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="org.springframework.jdbc.datasource.SimpleDriverDataSource">
        <property name="driverClass" value="org.apache.shardingsphere.driver.ShardingSphereDriver" />
        <property name="url" value="jdbc:shardingsphere:classpath:xxx.yaml" />
    </bean>
</beans>

Use Data Source #

Same with Spring Boot.