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/07/29 09:03:48 UTC

[GitHub] [incubator-shardingsphere] jaychang9 edited a comment on issue #2689: 与spring boot 集成后启动报错

jaychang9 edited a comment on issue #2689: 与spring boot 集成后启动报错
URL: https://github.com/apache/incubator-shardingsphere/issues/2689#issuecomment-515908434
 
 
   I use the springboot 2.1.6.RELEASE. I already exclude the JtaAutoConfiguration.class 
   `@SpringBootApplication(exclude = {JtaAutoConfiguration.class})`
   But it doesn't affect.
   
   **The following is the error info:**
   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
   
   
   Action:
   
   Consider the following:
   	If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
   	If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
   
   Disconnected from the target VM, address: '127.0.0.1:52709', transport: 'socket'
   
   Process finished with exit code 1
   
   **then my application.properties:**
   
   spring.shardingsphere.datasource.names=ds_0,ds_1
   
   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.jdbc-url=jdbc:mysql://localhost:3306/ds0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
   spring.shardingsphere.datasource.ds_0.username=root
   spring.shardingsphere.datasource.ds_0.password=
   
   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.jdbc-url=jdbc:mysql://localhost:3306/ds1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
   spring.shardingsphere.datasource.ds_1.username=root
   spring.shardingsphere.datasource.ds_1.password=
   
   spring.shardingsphere.sharding.default-database-strategy.inline.sharding-column=user_id
   spring.shardingsphere.sharding.default-database-strategy.inline.algorithm-expression=ds_$->{user_id % 2}
   
   spring.shardingsphere.sharding.tables.t_order.actual-data-nodes=ds$->{0..1}.t_order
   spring.shardingsphere.sharding.tables.t_order.key-generator.column=order_id
   spring.shardingsphere.sharding.tables.t_order.key-generator.type=SNOWFLAKE
   spring.shardingsphere.sharding.tables.t_order.key-generator.props.worker.id=123
   spring.shardingsphere.sharding.tables.t_order_item.actual-data-nodes=ds$->{0..3}.t_order_item
   spring.shardingsphere.sharding.tables.t_order_item.key-generator.column=order_item_id
   spring.shardingsphere.sharding.tables.t_order_item.key-generator.type=SNOWFLAKE
   spring.shardingsphere.sharding.tables.t_order_item.key-generator.props.worker.id=123
   
   spring.shardingsphere.props.sql.show=true
   
   **the following is my pom.xml**
   	<properties>
   		<java.version>1.8</java.version>
           <spring-boot.version>2.1.6.RELEASE</spring-boot.version>
           <sharding-sphere.version>4.0.0-RC1</sharding-sphere.version>
   	</properties>
   
   	<dependencies>
   		<dependency>
   			<groupId>org.springframework.boot</groupId>
   			<artifactId>spring-boot-starter-web</artifactId>
   		</dependency>
   		<dependency>
   			<groupId>org.mybatis.spring.boot</groupId>
   			<artifactId>mybatis-spring-boot-starter</artifactId>
   			<version>2.1.0</version>
   		</dependency>
   
           <dependency>
               <groupId>org.projectlombok</groupId>
               <artifactId>lombok</artifactId>
           </dependency>
           <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>sharding-jdbc-spring-boot-starter</artifactId>
               <version>4.0.0-RC1</version>
               <type>pom</type>
           </dependency>
   
   		<dependency>
   			<groupId>mysql</groupId>
   			<artifactId>mysql-connector-java</artifactId>
               <version>5.1.47</version>
   			<scope>runtime</scope>
   		</dependency>
   		<dependency>
   			<groupId>org.springframework.boot</groupId>
   			<artifactId>spring-boot-starter-test</artifactId>
   			<scope>test</scope>
   		</dependency>
   	</dependencies>
   
       <dependencyManagement>
           <dependencies>
               <dependency>
                   <groupId>org.springframework.boot</groupId>
                   <artifactId>spring-boot-starter-parent</artifactId>
                   <version>${spring-boot.version}</version>
                   <type>pom</type>
                   <scope>import</scope>
               </dependency>
           </dependencies>
       </dependencyManagement>
   
   I found springboot 1.5.x doesn't have this problem.

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