hanqingsong 3 år sedan
förälder
incheckning
75ab90e5d0
2 ändrade filer med 51 tillägg och 11 borttagningar
  1. 7 2
      pom.xml
  2. 44 9
      src/main/resources/bootstrap.yml

+ 7 - 2
pom.xml

@@ -28,6 +28,11 @@
28 28
 
29 29
 	<dependencies>
30 30
 		<dependency>
31
+			<groupId>org.apache.shardingsphere</groupId>
32
+			<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
33
+			<version>5.1.0</version>
34
+		</dependency>
35
+		<dependency>
31 36
 			<groupId>org.springframework.boot</groupId>
32 37
 			<artifactId>spring-boot-starter-web</artifactId>
33 38
 		</dependency>
@@ -174,14 +179,14 @@
174 179
 				<groupId>org.springframework.boot</groupId>
175 180
 				<artifactId>spring-boot-maven-plugin</artifactId>
176 181
 			</plugin>
177
-			<plugin>
182
+			<!--<plugin>
178 183
             	<groupId>org.apache.maven.plugins</groupId>
179 184
             	<artifactId>maven-war-plugin</artifactId>
180 185
             	<version>2.6</version>
181 186
             	<configuration>
182 187
                 	<failOnMissingWebXml>false</failOnMissingWebXml>
183 188
             	</configuration>
184
-        	</plugin>
189
+        	</plugin>-->
185 190
 		</plugins>
186 191
 		<!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 -->
187 192
 		<resources>

+ 44 - 9
src/main/resources/bootstrap.yml

@@ -6,7 +6,7 @@ server:
6 6
 eureka:
7 7
   client:
8 8
     service-url:
9
-      defaultZone: http://172.16.0.8:9001/eureka/,http://172.16.0.9:9001/eureka/
9
+      defaultZone: http://172.16.0.8:9001/eureka/
10 10
   instance:
11 11
     prefer-ip-address: true
12 12
     # 每隔10s发送一次心跳(默认30s)
@@ -16,17 +16,52 @@ eureka:
16 16
 spring:
17 17
   application:
18 18
     name: depot-basic
19
-
20
-  # 数据库配置
21
-  datasource:
22
-    driverClassName: com.mysql.cj.jdbc.Driver
23
-    url: jdbc:mysql://101.36.160.140:10311/depot_yunnan?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2b8
24
-    username: root
25
-    password: 123456
19
+  shardingsphere:
20
+    props:
21
+      sql-show: true
22
+    mode:
23
+      type: Standalone
24
+      overwrite: true
25
+      repository:
26
+        type: File
27
+        props:
28
+          path: D:/Standalone/depot-basic
29
+#          path: /home/depot/Standalone/depot-basic
30
+    datasource:
31
+      names: depot-master-01,depot-slave-01,depot-slave-02
32
+      depot-master-01:
33
+        type: com.zaxxer.hikari.HikariDataSource
34
+        driver-class-name: com.mysql.cj.jdbc.Driver
35
+        jdbc-url: jdbc:mysql://172.16.0.8:3306/depot?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
36
+        username: root
37
+        password: 123456
38
+      depot-slave-01:
39
+        type: com.zaxxer.hikari.HikariDataSource
40
+        driver-class-name: com.mysql.cj.jdbc.Driver
41
+        jdbc-url: jdbc:mysql://172.16.0.9:3306/depot?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
42
+        username: root
43
+        password: 123456
44
+      depot-slave-02:
45
+        type: com.zaxxer.hikari.HikariDataSource
46
+        driver-class-name: com.mysql.cj.jdbc.Driver
47
+        jdbc-url: jdbc:mysql://172.16.0.10:3306/depot?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
48
+        username: root
49
+        password: 123456
50
+    rules:
51
+      readwrite-splitting:
52
+        data-sources:
53
+          depot:
54
+            type: Static
55
+            props:
56
+              write-data-source-name: depot-master-01
57
+              read-data-source-names: depot-slave-01,depot-slave-02
58
+            load-balancer-name: depot_algorithm
59
+        load-balancers:
60
+          depot_algorithm:
61
+            type: ROUND_ROBIN
26 62
   # 缓存配置
27 63
   session:
28 64
     store-type: redis
29
-
30 65
   redis:
31 66
     database: 13
32 67
     host: 172.16.0.2