You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2019/12/30 05:18:51 UTC

[GitHub] [incubator-shardingsphere] LuciferZK opened a new issue #3831: sharding-jdbc-spring-boot-starter 4.0.0-RC2 integration version problem

LuciferZK opened a new issue #3831: sharding-jdbc-spring-boot-starter 4.0.0-RC2 integration version problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3831
 
 
   
   My English is not very good, I use Google Translate.
   
   _Description:
   
   Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
   
   Reason: Failed to determine a suitable driver class
   _
   pom.xml:
   ```java
   		<dependency>
               <groupId>org.mybatis.spring.boot</groupId>
               <artifactId>mybatis-spring-boot-starter</artifactId>
               <version>2.1.1</version>
           </dependency>
           <dependency>
               <groupId>com.alibaba</groupId>
               <artifactId>druid-spring-boot-starter</artifactId>
               <version>1.1.20</version>
           </dependency>
           <dependency>
               <groupId>mysql</groupId>
               <artifactId>mysql-connector-java</artifactId>
               <version>5.1.47</version>
           </dependency>
           <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>sharding-jdbc-spring-boot-starter</artifactId>
               <version>4.0.0-RC2</version>
           </dependency>
   ```
   sharding-jdbc-spring-boot-starter 4.0.0-RC2 integration will appear Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
   Change sharding-jdbc-spring-boot-starter to 4.0.0-RC1, this problem will not occur。
   
   application.yml:
   
       server:
         port: 56081
         servlet:
           context-path: /sharding-jdbc-examples
       spring:
         application:
           name: sharding-jdbc-examples
         http:
           encoding:
             enabled: true
             charset: utf-8
             force: true
         main:
           allow-bean-definition-overriding: true
         shardingsphere:
           datasource:
             names: m1
             m1:
               type: com.alibaba.druid.pool.DruidDataSource
               driverClassName: com.mysql.jdbc.Driver
               url: jdbc:mysql://localhost:3306/order_db?useUnicode=true
               username: root
               password: 123456
           sharding:
             tables:
               t_order:
                 actualDataNodes: m1.t_order_$->{1..2}
                 tableStrategy:
                   inline:
                     shardingColumn: order_id
                     algorithmExpression: t_order_$->{order_id % 2 + 1}
                 keyGenerator:
                   type: SNOWFLAKE
                   column: order_id
           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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] LuciferZK commented on issue #3831: sharding-jdbc-spring-boot-starter 4.0.0-RC2 integration version problem

Posted by GitBox <gi...@apache.org>.
LuciferZK commented on issue #3831: sharding-jdbc-spring-boot-starter 4.0.0-RC2 integration version problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3831#issuecomment-569616498
 
 
   Simple example, no code, only jar package and configuration;
   
   1.Create database order_db;
   
       CREATE DATABASE `order_db` CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';
   2.Create t_order_1, t_order_2 tables in order_db;
   
       DROP TABLE IF EXISTS `t_order_1`;
       CREATE TABLE `t_order_1` (
       `order_id` bigint(20) NOT NULL COMMENT '订单id',
       `price` decimal(10, 2) NOT NULL COMMENT '订单价格',
       `user_id` bigint(20) NOT NULL COMMENT '下单用户id',
       `status` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '订单状态',
       PRIMARY KEY (`order_id`) USING BTREE
       ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
       DROP TABLE IF EXISTS `t_order_2`;
       CREATE TABLE `t_order_2` (
       `order_id` bigint(20) NOT NULL COMMENT '订单id',
       `price` decimal(10, 2) NOT NULL COMMENT '订单价格',
       `user_id` bigint(20) NOT NULL COMMENT '下单用户id',
       `status` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '订单状态',
       PRIMARY KEY (`order_id`) USING BTREE
       ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
   
   3.application.yml:
   ```json
   #服务端口
   server:
     port: 56081
   #服务名
   spring:
     application:
       name: sharding-jdbc-examples
     http:
       encoding:
         enabled: true
         charset: utf-8
         force: true
     main:
      allow-bean-definition-overriding: true
     #shardingsphere相关配置
     shardingsphere:
       datasource:
         names: m1   #配置库的名字,随意
         m1:   #配置目前m1库的数据源信息
           type: com.alibaba.druid.pool.DruidDataSource
           driverClassName: com.mysql.jdbc.Driver
           url: jdbc:mysql://192.168.87.133:3306/order_db?useUnicode=true
           username: root
           password: 123456
       sharding:
         tables:
           t_order:  # 指定t_order表的数据分布情况,配置数据节点
             actualDataNodes: m1.t_order_$->{1..2}
             tableStrategy:
               inline:   # 指定t_order表的分片策略,分片策略包括分片键和分片算法
                 shardingColumn: order_id
                 algorithmExpression: t_order_$->{order_id % 2 + 1}
             keyGenerator:   # 指定t_order表的主键生成策略为SNOWFLAKE
               type: SNOWFLAKE  #主键生成策略为SNOWFLAKE
               column: order_id  #指定主键
       props:
         sql:
           show: true
   ```
   4.pom.xml
   ```xml
   <?xml version="1.0" encoding="UTF-8"?>
   <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
       <modelVersion>4.0.0</modelVersion>
       <parent>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-parent</artifactId>
           <version>2.2.2.RELEASE</version>
           <relativePath/> <!-- lookup parent from repository -->
       </parent>
       <groupId>com.Lucifer</groupId>
       <artifactId>sharding-jdbc-examples</artifactId>
       <version>0.0.1-SNAPSHOT</version>
       <name>sharding-jdbc-examples</name>
       <description>Demo project for Spring Boot</description>
   
       <properties>
           <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
           <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
           <java.version>1.8</java.version>
       </properties>
   
       <dependencies>
           <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter</artifactId>
           </dependency>
   
           <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter-test</artifactId>
           </dependency>
   
           <dependency>
               <groupId>org.mybatis.spring.boot</groupId>
               <artifactId>mybatis-spring-boot-starter</artifactId>
               <version>2.1.1</version>
           </dependency>
           <dependency>
               <groupId>com.alibaba</groupId>
               <artifactId>druid-spring-boot-starter</artifactId>
               <version>1.1.20</version>
           </dependency>
           <dependency>
               <groupId>mysql</groupId>
               <artifactId>mysql-connector-java</artifactId>
               <version>5.1.47</version>
           </dependency>
           <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>sharding-jdbc-spring-boot-starter</artifactId>
               <version>4.0.0-RC3</version>
           </dependency>
           <dependency>
               <groupId>com.baomidou</groupId>
               <artifactId>mybatis-plus-boot-starter</artifactId>
               <version>3.2.0</version>
           </dependency>
       </dependencies>
   
       <build>
           <plugins>
               <plugin>
                   <groupId>org.springframework.boot</groupId>
                   <artifactId>spring-boot-maven-plugin</artifactId>
               </plugin>
           </plugins>
       </build>
   
   </project>
   
   ```
    When sharding-jdbc-spring-boot-starter version is 4.0.0-RC2 or 4.0.0-RC3, even remove spring.main.allow-bean-definition-overriding: true, it still reports an error
   
   ![image](https://user-images.githubusercontent.com/38940745/71574167-8b0d2b80-2b22-11ea-8918-a3518670d5df.png)
   
   When sharding-jdbc-spring-boot-starter version is 4.0.0-RC1 and spring.main.allow-bean-definition-overriding: true is not deleted, no error is reported
   
   
   
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [shardingsphere] cnlinjie removed a comment on issue #3831: sharding-jdbc-spring-boot-starter 4.0.0-RC2 integration version problem

Posted by GitBox <gi...@apache.org>.
cnlinjie removed a comment on issue #3831:
URL: https://github.com/apache/shardingsphere/issues/3831#issuecomment-697684337


   问题依旧存在。


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shardingsphere] LuciferZK commented on issue #3831: sharding-jdbc-spring-boot-starter 4.0.0-RC2 integration version problem

Posted by GitBox <gi...@apache.org>.
LuciferZK commented on issue #3831: sharding-jdbc-spring-boot-starter 4.0.0-RC2 integration version problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3831#issuecomment-569609523
 
 
   > Sorry, I can't get your problem.
   > Do you mean that you configure the `url` of JDBC, but `shardingsphere` can't find the configuration?
   
   Yes, but when I downgraded the sharding-jdbc-spring-boot-starter from 4.0.0-RC2 to 4.0.0-RC1, no error is reported.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #3831: sharding-jdbc-spring-boot-starter 4.0.0-RC2 integration version problem

Posted by GitBox <gi...@apache.org>.
KomachiSion commented on issue #3831: sharding-jdbc-spring-boot-starter 4.0.0-RC2 integration version problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3831#issuecomment-569609693
 
 
   @LuciferZK , I have some advise for you, you can have a try to solve the problem.
   
   1. use `druid` replace `druid-spring-boot-starter`, and remove `main:allow-bean-definition-overriding: true` then retry.
   2. upgrade shardingsphere to 4.0.0-RC3 and retry.
   
   If the problem still happened, Please provide more detail log. Providing a example code to GitHub will be better.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #3831: sharding-jdbc-spring-boot-starter 4.0.0-RC2 integration version problem

Posted by GitBox <gi...@apache.org>.
KomachiSion commented on issue #3831: sharding-jdbc-spring-boot-starter 4.0.0-RC2 integration version problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3831#issuecomment-569604595
 
 
   Sorry, I can't get your problem. 
   Do you mean that you configure the `url` of JDBC, but `shardingsphere` can't find the configuration?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #3831: sharding-jdbc-spring-boot-starter 4.0.0-RC2 integration version problem

Posted by GitBox <gi...@apache.org>.
KomachiSion commented on issue #3831: sharding-jdbc-spring-boot-starter 4.0.0-RC2 integration version problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3831#issuecomment-569643074
 
 
   @LuciferZK , For my test, I found that the problem do not happen every time. So I think it maybe caused by the version conflict between spring dependence.
   
   After I exclude all spring dependence in `mybatis-plus-boot-starter`, `mybatis-spring-boot-starter` and `druid-spring-boot-starter`, and then specify all spring version 2.2.2.RELEASE, I can work well.
   
   Can you try to unite the version by exclusions and retry?
   
   [example code](https://github.com/KomachiSion/shardingsphere-issues/tree/master/issue3831)

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [shardingsphere] cnlinjie commented on issue #3831: sharding-jdbc-spring-boot-starter 4.0.0-RC2 integration version problem

Posted by GitBox <gi...@apache.org>.
cnlinjie commented on issue #3831:
URL: https://github.com/apache/shardingsphere/issues/3831#issuecomment-697684337


   问题依旧存在。


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shardingsphere] LuciferZK closed issue #3831: sharding-jdbc-spring-boot-starter 4.0.0-RC2 integration version problem

Posted by GitBox <gi...@apache.org>.
LuciferZK closed issue #3831: sharding-jdbc-spring-boot-starter 4.0.0-RC2 integration version problem
URL: https://github.com/apache/incubator-shardingsphere/issues/3831
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services