Skip to content

Commit 1441d5e

Browse files
author
Vincent.Li
committed
feat: add springcloud-app-nacos-config module for nacos config split use
1 parent 0da78c7 commit 1441d5e

File tree

27 files changed

+903
-42
lines changed

27 files changed

+903
-42
lines changed

pom.xml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
6-
7-
<parent>
8-
<groupId>org.springframework.boot</groupId>
9-
<artifactId>spring-boot-starter-parent</artifactId>
10-
<version>2.1.15.RELEASE</version>
11-
<relativePath/> <!-- lookup parent from repository -->
12-
</parent>
13-
146
<groupId>com.vincent</groupId>
157
<artifactId>springcloud-app-parent</artifactId>
168
<version>1.0-SNAPSHOT</version>
@@ -25,29 +17,29 @@
2517
<java.version>1.8</java.version>
2618
<maven.compiler.source>1.8</maven.compiler.source>
2719
<maven.compiler.target>1.8</maven.compiler.target>
28-
<spring-cloud.version>Greenwich.SR3</spring-cloud.version>
2920
<fastjson.version>1.2.68</fastjson.version>
3021
<apollo.version>1.5.1</apollo.version>
31-
<alibaba-cloud.version>2.1.1.RELEASE</alibaba-cloud.version>
32-
<nacos.version>2.1.1.RELEASE</nacos.version>
33-
<spring-gateway.version>2.2.0.RELEASE</spring-gateway.version>
22+
<spring-cloud.version>Hoxton.SR12</spring-cloud.version>
23+
<spring-boot.version>2.3.12.RELEASE</spring-boot.version>
24+
<alibaba-cloud.version>2.2.7.RELEASE</alibaba-cloud.version>
3425
<mybatis-generator.version>1.4.0</mybatis-generator.version>
3526
<pherialize.version>1.2.4</pherialize.version>
3627
<jedis.version>3.0.0</jedis.version>
3728
<commons-httpclient.version>3.1</commons-httpclient.version>
3829
<httpclient.version>4.5.13</httpclient.version>
3930
<druid.version>1.1.20</druid.version>
40-
<spring-web.version>5.1.11.RELEASE</spring-web.version>
31+
<!-- <spring-web.version>5.1.11.RELEASE</spring-web.version>-->
4132
<spring-kafka.version>2.2.11.RELEASE</spring-kafka.version>
4233
<dynamic-datasource.version>2.5.4</dynamic-datasource.version>
4334
<mybatis.version>2.1.1</mybatis.version>
4435
<es.version>7.4.0</es.version>
4536
<mybatis-plus.version>3.3.2</mybatis-plus.version>
46-
<spring-kafka.version>2.2.11.RELEASE</spring-kafka.version>
47-
<commons-lang3.version>3.1</commons-lang3.version>
37+
<commons-lang3.version>3.12.0</commons-lang3.version>
38+
<commons-pool2.version>2.11.1</commons-pool2.version>
4839
<gson.version>2.8.2</gson.version>
4940
<rocketmq-spring-boot-starter.version>2.1.1</rocketmq-spring-boot-starter.version>
5041
<seata.version>1.4.0</seata.version>
42+
<fst.version>2.57</fst.version>
5143
</properties>
5244
<dependencyManagement>
5345
<dependencies>
@@ -57,6 +49,14 @@
5749
<artifactId>lombok</artifactId>
5850
<version>1.18.2</version>
5951
</dependency>
52+
<!-- SpringBoot -->
53+
<dependency>
54+
<groupId>org.springframework.boot</groupId>
55+
<artifactId>spring-boot-dependencies</artifactId>
56+
<version>${spring-boot.version}</version>
57+
<type>pom</type>
58+
<scope>import</scope>
59+
</dependency>
6060
<dependency>
6161
<groupId>org.springframework.cloud</groupId>
6262
<artifactId>spring-cloud-dependencies</artifactId>
@@ -69,19 +69,9 @@
6969
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
7070
<version>${alibaba-cloud.version}</version>
7171
<type>pom</type>
72+
<scope>import</scope>
7273
</dependency>
73-
<!--nacos-->
74-
<dependency>
75-
<groupId>com.alibaba.cloud</groupId>
76-
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
77-
<version>${nacos.version}</version>
78-
</dependency>
79-
<!--gateway-->
80-
<dependency>
81-
<groupId>org.springframework.cloud</groupId>
82-
<artifactId>spring-cloud-starter-gateway</artifactId>
83-
<version>${spring-gateway.version}</version>
84-
</dependency>
74+
8575
<!--http-->
8676
<dependency>
8777
<groupId>org.apache.httpcomponents</groupId>
@@ -120,8 +110,11 @@
120110
<artifactId>jedis</artifactId>
121111
<version>${jedis.version}</version>
122112
</dependency>
123-
124-
113+
<dependency>
114+
<groupId>org.apache.commons</groupId>
115+
<artifactId>commons-pool2</artifactId>
116+
<version>${commons-pool2.version}</version>
117+
</dependency>
125118
<dependency>
126119
<groupId>org.apache.rocketmq</groupId>
127120
<artifactId>rocketmq-spring-boot-starter</artifactId>
@@ -146,6 +139,12 @@
146139
<version>${seata.version}</version>
147140
</dependency>
148141

142+
<dependency>
143+
<groupId>de.ruedigermoeller</groupId>
144+
<artifactId>fst</artifactId>
145+
<version>${fst.version}</version>
146+
</dependency>
147+
149148
</dependencies>
150149
</dependencyManagement>
151150

@@ -182,6 +181,7 @@
182181
<module>springcloud-app-config-bus-client</module>
183182
<module>springcloud-app-monitor</module>
184183
<module>springcloud-app-seata</module>
184+
<module>springcloud-app-nacos-config</module>
185185
</modules>
186186

187187

springcloud-app-api/src/main/java/com/vincent/springcloud/app/api/controller/PingController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.vincent.springcloud.app.api.controller;
22

33
import com.alibaba.fastjson.JSONObject;
4-
import com.vincent.springcloud.seata.common.constants.SystemConstants;
5-
import com.vincent.springcloud.seata.common.vo.resp.Response;
4+
import com.vincent.springcloud.common.model.vo.Response;
5+
import com.vincent.springcloud.common.constants.SystemConstants;
66
import lombok.extern.slf4j.Slf4j;
77
import org.springframework.beans.factory.annotation.Value;
88
import org.springframework.web.bind.annotation.*;

springcloud-app-common/pom.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919

2020
<dependencies>
2121

22-
<dependency>
23-
<groupId>org.springframework.boot</groupId>
24-
<artifactId>spring-boot-starter-web</artifactId>
25-
</dependency>
2622
<dependency>
2723
<groupId>org.apache.httpcomponents</groupId>
2824
<artifactId>httpclient</artifactId>
@@ -42,6 +38,7 @@
4238
<artifactId>spring-boot-maven-plugin</artifactId>
4339
<configuration>
4440
<skip>true</skip>
41+
<finalName>${project.name}</finalName>
4542
</configuration>
4643
</plugin>
4744
</plugins>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.vincent.springcloud.seata.common.constants;
1+
package com.vincent.springcloud.common.constants;
22

33
/**
44
* @author vincent.li
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.vincent.springcloud.common.enums;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Getter;
5+
6+
/**
7+
* 响应码枚举
8+
*
9+
* @author vincent.li
10+
* @date 2019/05/12
11+
*/
12+
@Getter
13+
@AllArgsConstructor
14+
public enum ResponseCodeEnum {
15+
16+
SYS_ERROR("SYS_ERROR", "系统繁忙,请稍后再试"),
17+
SUCCESS("200", "请求成功"),
18+
FAIL("500", "请求失败");
19+
20+
private final String code;
21+
private final String msg;
22+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
package com.vincent.springcloud.common.model.vo;
2+
3+
import com.vincent.springcloud.common.enums.ResponseCodeEnum;
4+
import lombok.Data;
5+
import org.apache.commons.lang3.StringUtils;
6+
7+
/**
8+
* 返回基类
9+
*
10+
* @author vincent.li
11+
* @date 2019/05/12
12+
*/
13+
@Data
14+
public class Response<T> {
15+
private static final long serialVersionUID = 1L;
16+
17+
/**
18+
* 是否成功
19+
*/
20+
private boolean success;
21+
/**
22+
* 响应码
23+
*/
24+
private String code;
25+
/**
26+
* 响应描述
27+
*/
28+
private String message;
29+
/**
30+
* 响应业务数据
31+
*/
32+
private T data;
33+
34+
public Response() {
35+
}
36+
37+
@Override
38+
public String toString() {
39+
return "Response [success=" + this.success + ", code=" + this.code + ", message=" + this.message + "]";
40+
}
41+
42+
public static Response buildSuccess() {
43+
Response response = new Response();
44+
response.setSuccess();
45+
return response;
46+
}
47+
48+
public static <T> Response<T> buildSuccess(T data) {
49+
Response response = buildSuccess();
50+
response.setData(data);
51+
return response;
52+
}
53+
54+
public static Response buildSuccess(String msg) {
55+
Response response = buildSuccess();
56+
response.setMessage(msg);
57+
return response;
58+
}
59+
60+
public static <T> Response<T> buildSuccess(T data, String msg) {
61+
Response response = buildSuccess();
62+
response.setData(data);
63+
response.setMessage(msg);
64+
return response;
65+
}
66+
67+
public static Response buildFailure(String code, String message) {
68+
Response response = new Response();
69+
response.setSuccess(false);
70+
response.setCode(code);
71+
response.setMessage(message);
72+
return response;
73+
}
74+
75+
public static Response buildFailure(ResponseCodeEnum responseCodeEnum) {
76+
return buildFailure(responseCodeEnum.getCode(), responseCodeEnum.getMsg());
77+
}
78+
79+
public static Response buildFailure(String msg) {
80+
return buildFailure(ResponseCodeEnum.FAIL.getCode(), StringUtils.isEmpty(msg) ? ResponseCodeEnum.FAIL.getMsg() : msg);
81+
}
82+
83+
public static Response buildFailure() {
84+
return buildFailure(ResponseCodeEnum.FAIL);
85+
}
86+
87+
public static Response buildSysError() {
88+
return buildFailure(ResponseCodeEnum.SYS_ERROR);
89+
}
90+
91+
public boolean isSuccess() {
92+
return ResponseCodeEnum.SUCCESS.getCode().equals(this.code);
93+
}
94+
95+
protected void setSuccess() {
96+
this.code = ResponseCodeEnum.SUCCESS.getCode();
97+
}
98+
99+
}

springcloud-app-feign-client/src/main/java/com/vincent/springcloud/app/feign/client/SpringcloudAppApiClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.vincent.springcloud.app.feign.client;
22

3-
import com.vincent.springcloud.seata.common.vo.resp.Response;
3+
import com.vincent.springcloud.common.model.vo.Response;
44
import org.springframework.cloud.openfeign.FeignClient;
55
import org.springframework.web.bind.annotation.GetMapping;
66
import org.springframework.web.bind.annotation.PathVariable;

springcloud-app-feign-client/src/main/java/com/vincent/springcloud/app/feign/client/SpringcloudAppApiHystrix.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.vincent.springcloud.app.feign.client;
22

3-
import com.vincent.springcloud.seata.common.vo.resp.Response;
3+
import com.vincent.springcloud.common.model.vo.Response;
44
import org.springframework.stereotype.Component;
55

66
/**

springcloud-app-feign-client/src/main/java/com/vincent/springcloud/app/feign/controller/PingController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.vincent.springcloud.app.feign.controller;
22

33
import com.alibaba.fastjson.JSONObject;
4-
import com.vincent.springcloud.seata.common.constants.SystemConstants;
5-
import com.vincent.springcloud.seata.common.vo.resp.Response;
4+
import com.vincent.springcloud.common.constants.SystemConstants;
65
import com.vincent.springcloud.app.feign.service.HelloService;
6+
import com.vincent.springcloud.common.model.vo.Response;
77
import org.springframework.beans.factory.annotation.Value;
88
import org.springframework.web.bind.annotation.*;
99

springcloud-app-feign-client/src/main/java/com/vincent/springcloud/app/feign/service/HelloService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.vincent.springcloud.app.feign.service;
22

3-
import com.vincent.springcloud.seata.common.vo.resp.Response;
43
import com.vincent.springcloud.app.feign.client.SpringcloudAppApiClient;
4+
import com.vincent.springcloud.common.model.vo.Response;
55
import lombok.extern.slf4j.Slf4j;
66
import org.springframework.stereotype.Component;
77

0 commit comments

Comments
 (0)