TeslaCN commented on issue #19541: URL: https://github.com/apache/shardingsphere/issues/19541#issuecomment-1198816071
I modify the example https://github.com/apache/shardingsphere/tree/master/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example to adapt PostgreSQL and run it. But the key generator worked. Changes: ``` wuweijie@wuweijie-ubuntu:~/projects/shardingsphere/examples (branch: master!) $ git diff | cat diff --git a/examples/example-core/example-spring-mybatis/src/main/resources/META-INF/mappers/AddressMapper.xml b/examples/example-core/example-spring-mybatis/src/main/resources/META-INF/mappers/AddressMapper.xml index 2ade012b8c3..690a8481fe9 100644 --- a/examples/example-core/example-spring-mybatis/src/main/resources/META-INF/mappers/AddressMapper.xml +++ b/examples/example-core/example-spring-mybatis/src/main/resources/META-INF/mappers/AddressMapper.xml @@ -24,7 +24,7 @@ </resultMap> <update id="createTableIfNotExists"> - CREATE TABLE IF NOT EXISTS t_address (address_id BIGINT NOT NULL, address_name VARCHAR(100) NOT NULL, PRIMARY KEY (address_id)); + CREATE TABLE IF NOT EXISTS t_address (address_id BIGINT primary key, address_name VARCHAR(100) NOT NULL); </update> <update id="truncateTable"> diff --git a/examples/example-core/example-spring-mybatis/src/main/resources/META-INF/mappers/OrderItemMapper.xml b/examples/example-core/example-spring-mybatis/src/main/resources/META-INF/mappers/OrderItemMapper.xml index 48aae459c00..d605bc541ec 100644 --- a/examples/example-core/example-spring-mybatis/src/main/resources/META-INF/mappers/OrderItemMapper.xml +++ b/examples/example-core/example-spring-mybatis/src/main/resources/META-INF/mappers/OrderItemMapper.xml @@ -26,7 +26,7 @@ </resultMap> <update id="createTableIfNotExists"> - CREATE TABLE IF NOT EXISTS t_order_item (order_item_id BIGINT AUTO_INCREMENT, order_id BIGINT, user_id INT NOT NULL, status VARCHAR(50) , PRIMARY KEY (order_item_id)); + CREATE TABLE IF NOT EXISTS t_order_item (order_item_id BIGINT primary key, order_id BIGINT, user_id INT NOT NULL, status VARCHAR(50)); </update> <update id="truncateTable"> diff --git a/examples/example-core/example-spring-mybatis/src/main/resources/META-INF/mappers/OrderMapper.xml b/examples/example-core/example-spring-mybatis/src/main/resources/META-INF/mappers/OrderMapper.xml index d32c53c0296..040b2d08b29 100644 --- a/examples/example-core/example-spring-mybatis/src/main/resources/META-INF/mappers/OrderMapper.xml +++ b/examples/example-core/example-spring-mybatis/src/main/resources/META-INF/mappers/OrderMapper.xml @@ -26,7 +26,7 @@ </resultMap> <update id="createTableIfNotExists"> - CREATE TABLE IF NOT EXISTS t_order (order_id BIGINT AUTO_INCREMENT, user_id INT NOT NULL, address_id BIGINT NOT NULL, status VARCHAR(50), PRIMARY KEY (order_id)); + CREATE TABLE IF NOT EXISTS t_order (order_id BIGINT primary key, user_id INT NOT NULL, address_id BIGINT NOT NULL, status VARCHAR(50)); </update> <update id="truncateTable"> diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/pom.xml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/pom.xml index 0a2d2a1125a..158661be90f 100644 --- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/pom.xml +++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/pom.xml @@ -48,5 +48,10 @@ <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <version>1.4.200</version> + </dependency> </dependencies> </project> diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases.properties b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases.properties index 1630ddc75b2..b06120ed98c 100644 --- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases.properties +++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases.properties @@ -17,17 +17,17 @@ spring.shardingsphere.datasource.names=ds-0,ds-1 -spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8 +spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:postgresql://localhost:5432/demo_ds_0 spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource -spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver -spring.shardingsphere.datasource.ds-0.username=root -spring.shardingsphere.datasource.ds-0.password= +spring.shardingsphere.datasource.ds-0.driver-class-name=org.postgresql.Driver +spring.shardingsphere.datasource.ds-0.username=postgres +spring.shardingsphere.datasource.ds-0.password=postgres -spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8 +spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:postgresql://localhost:5432/demo_ds_1 spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource -spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver -spring.shardingsphere.datasource.ds-1.username=root -spring.shardingsphere.datasource.ds-1.password= +spring.shardingsphere.datasource.ds-1.driver-class-name=org.postgresql.Driver +spring.shardingsphere.datasource.ds-1.username=postgres +spring.shardingsphere.datasource.ds-1.password=postgres spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database-inline ``` -- 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]
