pom文件如下
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>shardingsphere-jdbc-5.x-core-sample</artifactId>
<properties>
<shardingsphere.version>5.4.1</shardingsphere.version>
<spring-boot.version>2.7.18</spring-boot.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>4.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core</artifactId>
<version>${shardingsphere.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.2.224</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.2.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.oracle.database.jdbc/ojdbc6 -->
<!-- <dependency>-->
<!-- <groupId>com.oracle.database.jdbc</groupId>-->
<!-- <artifactId>ojdbc6</artifactId>-->
<!-- <version>11.2.0.4</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.33</version>
</dependency>
<!-- <!– https://mvnrepository.com/artifact/com.alibaba/druid –>-->
<!-- <dependency>-->
<!-- <groupId>com.alibaba</groupId>-->
<!-- <artifactId>druid</artifactId>-->
<!-- <version>1.2.20</version>-->
<!-- </dependency>-->
</dependencies>
</project>
application.yml
spring:
# dynamic-datasource 配置
datasource:
dynamic:
datasource:
master:
username: sa
password: ""
url: jdbc:h2:mem:baomidou_master;INIT=RUNSCRIPT FROM 'classpath:db/schema.sql'
driver-class-name: org.h2.Driver
test:
username: sa
password: ""
url: jdbc:h2:mem:baomidou_test;INIT=RUNSCRIPT FROM 'classpath:db/schema.sql'
driver-class-name: org.h2.Driver
testaaa:
username: username
password: password
url: url
driver-class-name: oracle.jdbc.OracleDriver
shardingSphere:
url: jdbc:shardingsphere:classpath:config.yaml
driver-class-name: org.apache.shardingsphere.driver.ShardingSphereDriver
logging:
level:
com.baomidou: debug
shardingshpere的配置文件如下
dataSources:
shardingmaster:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: oracle.jdbc.OracleDriver
jdbcUrl: url
username: username
password: password
# dataSourceClassName: com.zaxxer.hikari.HikariDataSource
# driverClassName: org.h2.Driver
# jdbcUrl: jdbc:h2:mem:slave1;INIT=RUNSCRIPT FROM 'classpath:db/schema.sql'
# username: sa
# password:
shardingslave0:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.h2.Driver
jdbcUrl: jdbc:h2:mem:slave1;INIT=RUNSCRIPT FROM 'classpath:db/schema.sql'
username: sa
password:
shardingslave1:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.h2.Driver
jdbcUrl: jdbc:h2:mem:slave2;INIT=RUNSCRIPT FROM 'classpath:db/schema.sql'
username: sa
password:
rules:
- !SHARDING
tables:
t_order:
actualDataNodes: shardingmaster.t_order$->{0..1}
tableStrategy:
standard:
shardingColumn: order_id
shardingAlgorithmName: baomidou_inline
keyGenerateStrategy:
column: order_id
keyGeneratorName: baomidou_snowflake
shardingAlgorithms:
baomidou_inline:
type: INLINE
props:
algorithm-expression: t_order$->{ORDER_ID % 2}
allow-range-query-with-inline-sharding: true
keyGenerators:
baomidou_snowflake:
type: SNOWFLAKE
- !READWRITE_SPLITTING
dataSources:
baomidou_readwrite_data_sources:
writeDataSourceName: shardingmaster
readDataSourceNames:
- shardingslave0
- shardingslave1
loadBalancerName: baomidou_load_balance_algorithm
loadBalancers:
baomidou_load_balance_algorithm:
type: ROUND_ROBIN
- !SINGLE
tables:
- "*.*"
props:
sql-show: true
换了ojdbc的无数个版本,换了druid。就是启动不起来
源码已上传到码云,https://gitee.com/kuaileqitian/shardingshpere-demo.git,各位大佬看看什么问题
数据库是oracle11g