13612687938 opened a new issue, #15629:
URL: https://github.com/apache/shardingsphere/issues/15629
## Bug Report
Current situation:
SpringBoot + Mybatis-Plus + MySQL8.0 + ShardingSphere-JDBC ===> SUCCESS
SpringBoot + SpringDataJPA + MySQL8.0 + ShardingSphere-JDBC ===> FAIL (read
and write both on write-ds)
detail code: (an API method just contain userRepository.findAll();)
/**
* query all list
*
* @return
*/
@GetMapping("/list")
public List<User> list() {
return userService.list();
}
expect:
write on write-ds, read on read-ds.
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- ShardingSphere -->
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>
application.properties just copy url
"https://github.com/apache/shardingsphere/blob/master/examples/shardingsphere-jdbc-example/single-feature-example/readwrite-splitting-example/readwrite-splitting-spring-boot-jpa-example/src/main/resources/application-readwrite-splitting.properties"
`spring.shardingsphere.datasource.names=write-ds,read-ds-0,read-ds-1
spring.shardingsphere.datasource.write-ds.jdbc-url=jdbc:mysql://localhost:3306/shardingsphere-main?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.datasource.write-ds.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.write-ds.driver-class-name=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.write-ds.username=root
spring.shardingsphere.datasource.write-ds.password=root
spring.shardingsphere.datasource.read-ds-0.jdbc-url=jdbc:mysql://localhost:3306/shardingsphere-slave1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.datasource.read-ds-0.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.read-ds-0.driver-class-name=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.read-ds-0.username=root
spring.shardingsphere.datasource.read-ds-0.password=root
spring.shardingsphere.datasource.read-ds-1.jdbc-url=jdbc:mysql://localhost:3306/shardingsphere-slave2?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.datasource.read-ds-1.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.read-ds-1.driver-class-name=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.read-ds-1.username=root
spring.shardingsphere.datasource.read-ds-1.password=root
spring.shardingsphere.rules.readwrite-splitting.data-sources.readwrite_ds.type=Static
spring.shardingsphere.rules.readwrite-splitting.data-sources.readwrite_ds.props.write-data-source-name=write-ds
spring.shardingsphere.rules.readwrite-splitting.data-sources.readwrite_ds.props.read-data-source-names=read-ds-0,read-ds-1
spring.shardingsphere.rules.readwrite-splitting.data-sources.readwrite_ds.load-balancer-name=round_robin
spring.shardingsphere.rules.readwrite-splitting.load-balancers.round_robin.type=ROUND_ROBIN
spring.shardingsphere.props.sql-show=true`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]