From b193aca288233ef3dae46dc53b1770451e875f06 Mon Sep 17 00:00:00 2001 From: xiongxiaoyang <773861846@qq.com> Date: Mon, 1 Jun 2020 11:31:05 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=BC=80=E5=90=AF=E5=88=86?= =?UTF-8?q?=E8=A1=A8=E5=8A=9F=E8=83=BD=EF=BC=88=E9=80=82=E7=94=A8=E4=BA=8E?= =?UTF-8?q?=E6=96=B0=E7=94=A8=E6=88=B7=EF=BC=89=EF=BC=8C=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AEspring.autoconfigure.exclud?= =?UTF-8?q?e=3Dio.shardingsphere.shardingjdbc.spring.boot.SpringBootConfig?= =?UTF-8?q?uration=E6=9D=A5=E5=85=B3=E9=97=AD=E5=88=86=E8=A1=A8=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=88=E9=80=82=E7=94=A8=E4=BA=8E=E8=80=81=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=8D=87=E7=BA=A7=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/application-common-dev.yml | 59 +++++++++---------- .../java2nb/novel/CrawlNovelApplication.java | 3 +- .../java2nb/novel/FrontNovelApplication.java | 2 +- 3 files changed, 31 insertions(+), 33 deletions(-) diff --git a/novel-common/src/main/resources/application-common-dev.yml b/novel-common/src/main/resources/application-common-dev.yml index 3db9741..e4321d0 100644 --- a/novel-common/src/main/resources/application-common-dev.yml +++ b/novel-common/src/main/resources/application-common-dev.yml @@ -28,43 +28,42 @@ spring: password: test123456 driver-class-name: com.mysql.cj.jdbc.Driver - ####使用shardingJdbc时, ####所有的jdbcType都不能是LONGVARCHAR,否则会导致java.io.NotSerializableException: java.io.StringReader错误 ##### 应该替换所有的 LONGVARCHAR 类型为VARCHAR -#sharding: -# jdbc: -# datasource: -# names: ds0 #,ds1 -# ds0: -# type: com.zaxxer.hikari.HikariDataSource -# driver-class-name: com.mysql.cj.jdbc.Driver -# jdbc-url: jdbc:mysql://localhost:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai +sharding: + jdbc: + datasource: + names: ds0 #,ds1 + ds0: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + jdbc-url: jdbc:mysql://localhost:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai + username: root + password: test123456 +# ds1: +# type: com.alibaba.druid.pool.DruidDataSource +# driver-class-name: com.mysql.jdbc.Driver +# url: jdbc:mysql://localhost:3306/novel_plus2 # username: root # password: test123456 -## ds1: -## type: com.alibaba.druid.pool.DruidDataSource -## driver-class-name: com.mysql.jdbc.Driver -## url: jdbc:mysql://localhost:3306/novel_plus2 -## username: root -## password: test123456 -# config: -# sharding: -# props: -# sql.show: true -# tables: -# book_content: #book_content表 -# key-generator-column-name: id #主键 -# actual-data-nodes: ds${0}.book_content${0..9} #数据节点 -## database-strategy: #分库策略 -## inline: -## sharding-column: book_id -## algorithm-expression: ds${book_id % 10} -# table-strategy: #分表策略 + config: + sharding: + props: + sql.show: true + tables: + book_content: #book_content表 + key-generator-column-name: id #主键 + actual-data-nodes: ds${0}.book_content${0..9} #数据节点 +# database-strategy: #分库策略 # inline: -# shardingColumn: index_id -# algorithm-expression: book_content${index_id % 10} +# sharding-column: book_id +# algorithm-expression: ds${book_id % 10} + table-strategy: #分表策略 + inline: + shardingColumn: index_id + algorithm-expression: book_content${index_id % 10} diff --git a/novel-crawl/src/main/java/com/java2nb/novel/CrawlNovelApplication.java b/novel-crawl/src/main/java/com/java2nb/novel/CrawlNovelApplication.java index 8b0e12f..f4e4555 100644 --- a/novel-crawl/src/main/java/com/java2nb/novel/CrawlNovelApplication.java +++ b/novel-crawl/src/main/java/com/java2nb/novel/CrawlNovelApplication.java @@ -1,6 +1,5 @@ package com.java2nb.novel; -import io.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -11,7 +10,7 @@ import org.springframework.scheduling.annotation.EnableScheduling; /** * @author Administrator */ -@SpringBootApplication(exclude = {SpringBootConfiguration.class}) +@SpringBootApplication @EnableCaching @EnableScheduling @ServletComponentScan diff --git a/novel-front/src/main/java/com/java2nb/novel/FrontNovelApplication.java b/novel-front/src/main/java/com/java2nb/novel/FrontNovelApplication.java index 61869e4..f83b2d9 100644 --- a/novel-front/src/main/java/com/java2nb/novel/FrontNovelApplication.java +++ b/novel-front/src/main/java/com/java2nb/novel/FrontNovelApplication.java @@ -16,7 +16,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; /** * @author Administrator */ -@SpringBootApplication(exclude = {SpringBootConfiguration.class}) +@SpringBootApplication @EnableTransactionManagement @EnableScheduling @EnableCaching