Compare commits
7 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
b366fdb706 | |
|
|
3e0c244de4 | |
|
|
e178a14737 | |
|
|
2adf026f0b | |
|
|
8124047101 | |
|
|
157e3511fd | |
|
|
0085f6bfc5 |
|
|
@ -31,7 +31,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
<version>2.3.4.RELEASE</version>
|
<version>${springboot.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
|
|
@ -55,7 +55,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.kafka</groupId>
|
<groupId>org.springframework.kafka</groupId>
|
||||||
<artifactId>spring-kafka</artifactId>
|
<artifactId>spring-kafka</artifactId>
|
||||||
<version>2.7.6</version>
|
<version>2.8.11</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
|
|
@ -75,6 +75,8 @@
|
||||||
<version>9.0.38</version>
|
<version>9.0.38</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package cn.org.gitlink.notification.common.utils;
|
package cn.org.gitlink.notification.common.utils;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
@ -96,7 +98,7 @@ public class RedisUtil {
|
||||||
if (key.length == 1) {
|
if (key.length == 1) {
|
||||||
redisTemplate.delete(key[0]);
|
redisTemplate.delete(key[0]);
|
||||||
} else {
|
} else {
|
||||||
redisTemplate.delete(CollectionUtils.arrayToList(key));
|
redisTemplate.delete((Collection) CollectionUtils.arrayToList(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,40 @@
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
<version>${spring-cloud-alibaba.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
<version>${spring-cloud-alibaba.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
<version>${springboot.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Swagger -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
<version>${swagger.fox.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- knife4j -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||||
|
<version>${knife4j-spring-boot-starter.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.validation</groupId>
|
||||||
|
<artifactId>validation-api</artifactId>
|
||||||
|
<version>2.0.1.Final</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
@ -41,6 +75,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,14 @@ package cn.org.gitlink.notification.executor;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
@ComponentScan("cn.org.gitlink.notification.*")
|
@ComponentScan("cn.org.gitlink.notification.*")
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
|
@EnableDiscoveryClient
|
||||||
public class ExecutorApplication {
|
public class ExecutorApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(ExecutorApplication.class, args);}
|
SpringApplication.run(ExecutorApplication.class, args);}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,27 @@ logging:
|
||||||
config: classpath:logback.xml
|
config: classpath:logback.xml
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: microservices-gns-executor
|
||||||
|
mvc:
|
||||||
|
pathmatch:
|
||||||
|
matching-strategy: ant_path_matcher
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: ${nacos_ip}:${nacos_port}
|
||||||
|
username: ${nacos_username}
|
||||||
|
password: ${nacos_password}
|
||||||
|
config:
|
||||||
|
# 配置中心地址
|
||||||
|
server-addr: ${nacos_ip}:${nacos_port}
|
||||||
|
username: ${nacos_username}
|
||||||
|
password: ${nacos_password}
|
||||||
kafka:
|
kafka:
|
||||||
producer:
|
producer:
|
||||||
bootstrap_servers: kafka1:9092,kafka2:9092
|
bootstrap_servers: kafka1:9092,kafka2:9092
|
||||||
|
|
@ -44,7 +65,7 @@ spring:
|
||||||
timeout: 1000
|
timeout: 1000
|
||||||
|
|
||||||
datasource:
|
datasource:
|
||||||
driver-class-name: com.mysql.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://mysql:3306/gitlink_notification?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8&allowMultiQueries=true&useSSL=false
|
url: jdbc:mysql://mysql:3306/gitlink_notification?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8&allowMultiQueries=true&useSSL=false
|
||||||
username: gitlink
|
username: gitlink
|
||||||
password: giTlinK0^827
|
password: giTlinK0^827
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,14 @@ GNS_EXECUTOR_CONTAINER_NAME=gns_executor
|
||||||
GNS_READER_CONTAINER_NAME=gns_reader
|
GNS_READER_CONTAINER_NAME=gns_reader
|
||||||
GNS_WRITER_CONTAINER_NAME=gns_writer
|
GNS_WRITER_CONTAINER_NAME=gns_writer
|
||||||
|
|
||||||
|
#============================================ nacos config ============================================
|
||||||
|
NACOS_CONTAINER_NAME=cmdb-nacos
|
||||||
|
NACOS_NETWORK_NAME=docker-microservices-offline_default
|
||||||
|
NACOS_IP=cmdb-nacos
|
||||||
|
NACOS_PORT=8848
|
||||||
|
NACOS_USERNAME=nacos
|
||||||
|
NACOS_PASSWORD=nacos
|
||||||
|
|
||||||
#============================================ Ports config ============================================
|
#============================================ Ports config ============================================
|
||||||
|
|
||||||
MYSQL_LOCAL_PORT=33306
|
MYSQL_LOCAL_PORT=33306
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,4 @@ FROM openjdk:11.0.12-jre-slim
|
||||||
COPY executor/target/gns-executor-1.0.0.jar /data/gns-executor-app.jar
|
COPY executor/target/gns-executor-1.0.0.jar /data/gns-executor-app.jar
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
EXPOSE 8083
|
EXPOSE 8083
|
||||||
ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS gns-executor-app.jar"]
|
ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS gns-executor-app.jar $NACOS_OPTS"]
|
||||||
|
|
@ -0,0 +1,419 @@
|
||||||
|
# ConfigMap 用于存储环境变量
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: gns-config
|
||||||
|
namespace: gns
|
||||||
|
data:
|
||||||
|
MYSQL_DATABASE: "gitlink_notification"
|
||||||
|
---
|
||||||
|
# Redis Deployment
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: gns-redis
|
||||||
|
namespace: gns
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: gns-redis
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: gns-redis
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: gns-redis
|
||||||
|
image: redis:5.0
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
env:
|
||||||
|
- name: TZ
|
||||||
|
value: "Asia/Shanghai"
|
||||||
|
ports:
|
||||||
|
- containerPort: 6379
|
||||||
|
volumeMounts:
|
||||||
|
- name: redis-data
|
||||||
|
mountPath: /data
|
||||||
|
- name: redis-logs
|
||||||
|
mountPath: /logs
|
||||||
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: gns-config
|
||||||
|
volumes:
|
||||||
|
- name: redis-data
|
||||||
|
hostPath:
|
||||||
|
path: /data/gitlink-notification-system/docker-data/redis/data
|
||||||
|
- name: redis-logs
|
||||||
|
hostPath:
|
||||||
|
path: /data/gitlink-notification-system/docker-data/redis/logs
|
||||||
|
|
||||||
|
---
|
||||||
|
# Redis Service
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: gns-redis
|
||||||
|
namespace: gns
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: gns-redis
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 6379
|
||||||
|
targetPort: 6379
|
||||||
|
type: ClusterIP
|
||||||
|
---
|
||||||
|
# Zookeeper Deployment
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: gns-zookeeper
|
||||||
|
namespace: gns
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: gns-zookeeper
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: gns-zookeeper
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: gns-zookeeper
|
||||||
|
image: confluentinc/cp-zookeeper:latest
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
env:
|
||||||
|
- name: ZOOKEEPER_CLIENT_PORT
|
||||||
|
value: "2181"
|
||||||
|
- name: ZOOKEEPER_TICK_TIME
|
||||||
|
value: "2000"
|
||||||
|
ports:
|
||||||
|
- containerPort: 2181
|
||||||
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: gns-config
|
||||||
|
volumes:
|
||||||
|
- name: zookeeper-data
|
||||||
|
hostPath:
|
||||||
|
path: /data/gitlink-notification-system/docker-data/zookeeper
|
||||||
|
|
||||||
|
---
|
||||||
|
# Zookeeper Service
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: gns-zookeeper
|
||||||
|
namespace: gns
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: gns-zookeeper
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 2181
|
||||||
|
targetPort: 2181
|
||||||
|
type: ClusterIP
|
||||||
|
---
|
||||||
|
# Kafka1 Deployment
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: gns-kafka1
|
||||||
|
namespace: gns
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: gns-kafka1
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: gns-kafka1
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: gns-kafka1
|
||||||
|
image: confluentinc/cp-kafka:latest
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
env:
|
||||||
|
- name: KAFKA_BROKER_ID
|
||||||
|
value: "1"
|
||||||
|
- name: KAFKA_ZOOKEEPER_CONNECT
|
||||||
|
value: "gns-zookeeper:2181"
|
||||||
|
- name: KAFKA_ADVERTISED_LISTENERS
|
||||||
|
value: "PLAINTEXT://gns-kafka1:9092,PLAINTEXT_HOST://localhost:29092"
|
||||||
|
- name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
|
||||||
|
value: "PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT"
|
||||||
|
- name: KAFKA_INTER_BROKER_LISTENER_NAME
|
||||||
|
value: "PLAINTEXT"
|
||||||
|
- name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
|
||||||
|
value: "1"
|
||||||
|
ports:
|
||||||
|
- containerPort: 9092
|
||||||
|
- containerPort: 29092
|
||||||
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: gns-config
|
||||||
|
volumes:
|
||||||
|
- name: kafka-data
|
||||||
|
hostPath:
|
||||||
|
path: /data/gitlink-notification-system/docker-data/kafka/gns_kafka1/lib
|
||||||
|
- name: kafka-logs
|
||||||
|
hostPath:
|
||||||
|
path: /data/gitlink-notification-system/docker-data/kafka/gns_kafka1/logs
|
||||||
|
- name: kafka-conf
|
||||||
|
hostPath:
|
||||||
|
path: /data/gitlink-notification-system/docker-data/kafka/gns_kafka1/conf
|
||||||
|
|
||||||
|
---
|
||||||
|
# Kafka1 Service
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: gns-kafka1
|
||||||
|
namespace: gns
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: gns-kafka1
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 9092
|
||||||
|
targetPort: 9092
|
||||||
|
name: kafka1-9092
|
||||||
|
- protocol: TCP
|
||||||
|
port: 29092
|
||||||
|
targetPort: 29092
|
||||||
|
name: kafka1-29092
|
||||||
|
type: ClusterIP
|
||||||
|
---
|
||||||
|
# Kafka2 Deployment
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: gns-kafka2
|
||||||
|
namespace: gns
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: gns-kafka2
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: gns-kafka2
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: gns-kafka2
|
||||||
|
image: confluentinc/cp-kafka:latest
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
env:
|
||||||
|
- name: KAFKA_BROKER_ID
|
||||||
|
value: "2"
|
||||||
|
- name: KAFKA_ZOOKEEPER_CONNECT
|
||||||
|
value: "gns-zookeeper:2181"
|
||||||
|
- name: KAFKA_ADVERTISED_LISTENERS
|
||||||
|
value: "PLAINTEXT://gns-kafka2:9092,PLAINTEXT_HOST://localhost:39092"
|
||||||
|
- name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
|
||||||
|
value: "PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT"
|
||||||
|
- name: KAFKA_INTER_BROKER_LISTENER_NAME
|
||||||
|
value: "PLAINTEXT"
|
||||||
|
- name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
|
||||||
|
value: "1"
|
||||||
|
ports:
|
||||||
|
- containerPort: 9092
|
||||||
|
- containerPort: 39092
|
||||||
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: gns-config
|
||||||
|
volumes:
|
||||||
|
- name: kafka-data
|
||||||
|
hostPath:
|
||||||
|
path: /data/gitlink-notification-system/docker-data/kafka/gns_kafka2/lib
|
||||||
|
- name: kafka-logs
|
||||||
|
hostPath:
|
||||||
|
path: /data/gitlink-notification-system/docker-data/kafka/gns_kafka2/logs
|
||||||
|
- name: kafka-conf
|
||||||
|
hostPath:
|
||||||
|
path: /data/gitlink-notification-system/docker-data/kafka/gns_kafka2/conf
|
||||||
|
|
||||||
|
---
|
||||||
|
# Kafka2 Service
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: gns-kafka2
|
||||||
|
namespace: gns
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: gns-kafka2
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 9092
|
||||||
|
targetPort: 9092
|
||||||
|
name: kafka2-9092
|
||||||
|
- protocol: TCP
|
||||||
|
port: 39092
|
||||||
|
targetPort: 39092
|
||||||
|
name: kafka2-29092
|
||||||
|
type: ClusterIP
|
||||||
|
---
|
||||||
|
# GNS Reader Deployment
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: gns-reader
|
||||||
|
namespace: gns
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: gns-reader
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: gns-reader
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: gns-reader
|
||||||
|
image: gitlink/gns-reader:1.0.0
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
env:
|
||||||
|
- name: NACOS_OPTS
|
||||||
|
value: "--nacos_ip=gitlink-nacos.microservices.svc --nacos_port=8848 --nacos_username=nacos --nacos_password=nacos"
|
||||||
|
- name: TZ
|
||||||
|
value: "Asia/Shanghai"
|
||||||
|
ports:
|
||||||
|
- containerPort: 8081
|
||||||
|
volumeMounts:
|
||||||
|
- name: logs
|
||||||
|
mountPath: /data/logs
|
||||||
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: gns-config
|
||||||
|
volumes:
|
||||||
|
- name: logs
|
||||||
|
hostPath:
|
||||||
|
path: /data/gitlink-notification-system/docker-data/gitlink
|
||||||
|
---
|
||||||
|
# GNS Reader Service
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: gns-reader
|
||||||
|
namespace: gns
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: gns-reader
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 8081
|
||||||
|
targetPort: 8081
|
||||||
|
type: ClusterIP
|
||||||
|
---
|
||||||
|
# GNS Writer Deployment
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: gns-writer
|
||||||
|
namespace: gns
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: gns-writer
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: gns-writer
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: gns-writer
|
||||||
|
image: gitlink/gns-writer:1.0.0
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
env:
|
||||||
|
- name: NACOS_OPTS
|
||||||
|
value: "--nacos_ip=gitlink-nacos.microservices.svc --nacos_port=8848 --nacos_username=nacos --nacos_password=nacos"
|
||||||
|
- name: TZ
|
||||||
|
value: "Asia/Shanghai"
|
||||||
|
ports:
|
||||||
|
- containerPort: 8082
|
||||||
|
volumeMounts:
|
||||||
|
- name: logs
|
||||||
|
mountPath: /data/logs
|
||||||
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: gns-config
|
||||||
|
volumes:
|
||||||
|
- name: logs
|
||||||
|
hostPath:
|
||||||
|
path: /data/gitlink-notification-system/docker-data/gitlink
|
||||||
|
|
||||||
|
---
|
||||||
|
# GNS Writer Service
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: gns-writer
|
||||||
|
namespace: gns
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: gns-writer
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 8082
|
||||||
|
targetPort: 8082
|
||||||
|
type: ClusterIP
|
||||||
|
---
|
||||||
|
# GNS Executor Deployment
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: gns-executor
|
||||||
|
namespace: gns
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: gns-executor
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: gns-executor
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: gns-executor
|
||||||
|
image: gitlink/gns-executor:1.0.0
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
env:
|
||||||
|
- name: NACOS_OPTS
|
||||||
|
value: "--nacos_ip=gitlink-nacos.microservices.svc --nacos_port=8848 --nacos_username=nacos --nacos_password=nacos"
|
||||||
|
- name: TZ
|
||||||
|
value: "Asia/Shanghai"
|
||||||
|
ports:
|
||||||
|
- containerPort: 8083
|
||||||
|
volumeMounts:
|
||||||
|
- name: logs
|
||||||
|
mountPath: /data/logs
|
||||||
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: gns-config
|
||||||
|
volumes:
|
||||||
|
- name: logs
|
||||||
|
hostPath:
|
||||||
|
path: /data/gitlink-notification-system/docker-data/gitlink
|
||||||
|
|
||||||
|
---
|
||||||
|
# GNS Executor Service
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: gns-executor
|
||||||
|
namespace: gns
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: gns-executor
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 8083
|
||||||
|
targetPort: 8083
|
||||||
|
type: ClusterIP
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolume
|
||||||
|
metadata:
|
||||||
|
name: gns-mysql-pv
|
||||||
|
namespace: gns
|
||||||
|
spec:
|
||||||
|
capacity:
|
||||||
|
storage: 10Gi
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
storageClassName: "gns-mysql-pv" # 确保这个 storageClassName 与 PVC 中的匹配
|
||||||
|
hostPath:
|
||||||
|
path: "/data/gitlink-notification-system/docker-data/mysql"
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
# PersistentVolumeClaim 用于存储卷
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: gns-mysql-pvc
|
||||||
|
namespace: gns
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
storageClassName: "gns-mysql-pv"
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
---
|
||||||
|
# Secret 用于存储敏感信息
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: gns-secret
|
||||||
|
namespace: gns
|
||||||
|
type: Opaque
|
||||||
|
data:
|
||||||
|
MYSQL_ROOT_PASSWORD: "Z2l0TGlOa184Mjc="
|
||||||
|
MYSQL_USER: "Z2l0bGluaw=="
|
||||||
|
MYSQL_PASSWORD: "Z2lUbGluSzBeODI3"
|
||||||
|
#---
|
||||||
|
## gns-mysql-pv 用于存储 MySQL 数据
|
||||||
|
#apiVersion: v1
|
||||||
|
#kind: PersistentVolume
|
||||||
|
#metadata:
|
||||||
|
# name: gns-mysql-pv
|
||||||
|
# namespace: gns
|
||||||
|
#spec:
|
||||||
|
# capacity:
|
||||||
|
# storage: 10Gi
|
||||||
|
# accessModes:
|
||||||
|
# - ReadWriteOnce
|
||||||
|
# storageClassName: "gns-mysql-pv" # 确保这个 storageClassName 与 PVC 中的匹配
|
||||||
|
# hostPath:
|
||||||
|
# path: "/data/gitlink-notification-system/docker-data/mysql"
|
||||||
|
#---
|
||||||
|
## PersistentVolumeClaim 用于存储卷
|
||||||
|
#apiVersion: v1
|
||||||
|
#kind: PersistentVolumeClaim
|
||||||
|
#metadata:
|
||||||
|
# name: gns-mysql-pvc
|
||||||
|
# namespace: gns
|
||||||
|
#spec:
|
||||||
|
# accessModes:
|
||||||
|
# - ReadWriteOnce
|
||||||
|
# storageClassName: "gns-mysql-pv"
|
||||||
|
# resources:
|
||||||
|
# requests:
|
||||||
|
# storage: 10Gi
|
||||||
|
---
|
||||||
|
# MySQL Deployment
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: gns-mysql
|
||||||
|
namespace: gns
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: gns-mysql
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: gns-mysql
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: gns-mysql
|
||||||
|
image: mysql:5.7
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
env:
|
||||||
|
- name: MYSQL_ROOT_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: gns-secret
|
||||||
|
key: MYSQL_ROOT_PASSWORD
|
||||||
|
- name: MYSQL_USER
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: gns-secret
|
||||||
|
key: MYSQL_USER
|
||||||
|
- name: MYSQL_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: gns-secret
|
||||||
|
key: MYSQL_PASSWORD
|
||||||
|
- name: MYSQL_DATABASE
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: gns-config
|
||||||
|
key: MYSQL_DATABASE
|
||||||
|
- name: TZ
|
||||||
|
value: "Asia/Shanghai"
|
||||||
|
ports:
|
||||||
|
- containerPort: 3306
|
||||||
|
volumeMounts:
|
||||||
|
- name: mysql-data
|
||||||
|
mountPath: /var/lib/mysql
|
||||||
|
- name: sql-scripts
|
||||||
|
mountPath: /docker-entrypoint-initdb.d
|
||||||
|
command: ["/entrypoint.sh"]
|
||||||
|
args: ["mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci","--bind-address=0.0.0.0"]
|
||||||
|
volumes:
|
||||||
|
- name: mysql-data
|
||||||
|
hostPath:
|
||||||
|
path: /data/gitlink-notification-system/docker-data/mysql
|
||||||
|
type: DirectoryOrCreate
|
||||||
|
- name: sql-scripts
|
||||||
|
hostPath:
|
||||||
|
path: /data/gitlink-notification-system/db
|
||||||
|
---
|
||||||
|
# MySQL Service
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: gns-mysql-service
|
||||||
|
namespace: gns
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: gns-mysql
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 3306
|
||||||
|
targetPort: 3306
|
||||||
|
type: ClusterIP
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
#先在middleware目录下配置好.env中的参数
|
||||||
|
cd ../
|
||||||
|
|
||||||
|
#构建基础镜像
|
||||||
|
docker-compose -f services.yml build
|
||||||
|
|
||||||
|
#创建gns的命名空间
|
||||||
|
kubectl create namespace gns
|
||||||
|
|
||||||
|
#应用MySQL部署配置文件
|
||||||
|
kubectl apply -f gns-mysql.yaml
|
||||||
|
|
||||||
|
#应用GNS部署配置文件
|
||||||
|
kubectl apply -f gns-deployment.yaml
|
||||||
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
docker load -i gns-executor-1.0.0.tar.gz
|
||||||
|
docker load -i gns-reader-1.0.0.tar.gz
|
||||||
|
docker load -i gns-writer-1.0.0.tar.gz
|
||||||
|
docker load -i cp-kafka-latest.tar.gz
|
||||||
|
docker load -i cp-zookeeper-latest.tar.gz
|
||||||
|
docker load -i mysql-5.7.35.tar.gz
|
||||||
|
docker load -i redis-6.2.5.tar.gz
|
||||||
|
|
@ -10,4 +10,4 @@ FROM openjdk:11.0.12-jre-slim
|
||||||
COPY reader/target/gns-reader-1.0.0.jar /data/gns-reader-app.jar
|
COPY reader/target/gns-reader-1.0.0.jar /data/gns-reader-app.jar
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
EXPOSE 8081
|
EXPOSE 8081
|
||||||
ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS gns-reader-app.jar"]
|
ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS gns-reader-app.jar $NACOS_OPTS"]
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
docker save gitlink/gns-executor:1.0.0 | gzip > gns-executor-1.0.0.tar.gz
|
||||||
|
docker save gitlink/gns-reader:1.0.0 | gzip > gns-reader-1.0.0.tar.gz
|
||||||
|
docker save gitlink/gns-writer:1.0.0 | gzip > gns-writer-1.0.0.tar.gz
|
||||||
|
docker save confluentinc/cp-kafka:latest | gzip > cp-kafka-latest.tar.gz
|
||||||
|
docker save confluentinc/cp-zookeeper:latest | gzip > cp-zookeeper-latest.tar.gz
|
||||||
|
docker save mysql:5.7.35 | gzip > mysql-5.7.35.tar.gz
|
||||||
|
docker save redis:6.2.5 | gzip > redis-6.2.5.tar.gz
|
||||||
|
|
@ -111,8 +111,10 @@ services:
|
||||||
context: ../
|
context: ../
|
||||||
dockerfile: middleware/reader.Dockerfile
|
dockerfile: middleware/reader.Dockerfile
|
||||||
networks:
|
networks:
|
||||||
|
- microservices_network
|
||||||
- gitlink_network
|
- gitlink_network
|
||||||
environment:
|
environment:
|
||||||
|
- NACOS_OPTS=--nacos_ip=${NACOS_IP} --nacos_port=${NACOS_PORT} --nacos_username=${NACOS_USERNAME} --nacos_password=${NACOS_PASSWORD}
|
||||||
- TZ=Asia/Shanghai
|
- TZ=Asia/Shanghai
|
||||||
volumes:
|
volumes:
|
||||||
- ${DOCKER_DATA_PATH}/gitlink/:/data/logs/
|
- ${DOCKER_DATA_PATH}/gitlink/:/data/logs/
|
||||||
|
|
@ -121,6 +123,8 @@ services:
|
||||||
- kafka2
|
- kafka2
|
||||||
- redis
|
- redis
|
||||||
- mysql
|
- mysql
|
||||||
|
external_links:
|
||||||
|
- ${NACOS_CONTAINER_NAME}
|
||||||
ports:
|
ports:
|
||||||
- ${GNS_READER_LOCAL_PORT}:8081
|
- ${GNS_READER_LOCAL_PORT}:8081
|
||||||
restart: always
|
restart: always
|
||||||
|
|
@ -133,8 +137,10 @@ services:
|
||||||
context: ../
|
context: ../
|
||||||
dockerfile: middleware/writer.Dockerfile
|
dockerfile: middleware/writer.Dockerfile
|
||||||
networks:
|
networks:
|
||||||
|
- microservices_network
|
||||||
- gitlink_network
|
- gitlink_network
|
||||||
environment:
|
environment:
|
||||||
|
- NACOS_OPTS=--nacos_ip=${NACOS_IP} --nacos_port=${NACOS_PORT} --nacos_username=${NACOS_USERNAME} --nacos_password=${NACOS_PASSWORD}
|
||||||
- TZ=Asia/Shanghai
|
- TZ=Asia/Shanghai
|
||||||
volumes:
|
volumes:
|
||||||
- ${DOCKER_DATA_PATH}/gitlink/:/data/logs/
|
- ${DOCKER_DATA_PATH}/gitlink/:/data/logs/
|
||||||
|
|
@ -143,6 +149,8 @@ services:
|
||||||
- kafka2
|
- kafka2
|
||||||
- redis
|
- redis
|
||||||
- mysql
|
- mysql
|
||||||
|
external_links:
|
||||||
|
- ${NACOS_CONTAINER_NAME}
|
||||||
ports:
|
ports:
|
||||||
- ${GNS_WRITER_LOCAL_PORT}:8082
|
- ${GNS_WRITER_LOCAL_PORT}:8082
|
||||||
restart: always
|
restart: always
|
||||||
|
|
@ -155,16 +163,20 @@ services:
|
||||||
context: ../
|
context: ../
|
||||||
dockerfile: middleware/executor.Dockerfile
|
dockerfile: middleware/executor.Dockerfile
|
||||||
networks:
|
networks:
|
||||||
|
- microservices_network
|
||||||
- gitlink_network
|
- gitlink_network
|
||||||
volumes:
|
volumes:
|
||||||
- ${DOCKER_DATA_PATH}/gitlink/:/data/logs/
|
- ${DOCKER_DATA_PATH}/gitlink/:/data/logs/
|
||||||
environment:
|
environment:
|
||||||
|
- NACOS_OPTS=--nacos_ip=${NACOS_IP} --nacos_port=${NACOS_PORT} --nacos_username=${NACOS_USERNAME} --nacos_password=${NACOS_PASSWORD}
|
||||||
- TZ=Asia/Shanghai
|
- TZ=Asia/Shanghai
|
||||||
depends_on:
|
depends_on:
|
||||||
- kafka1
|
- kafka1
|
||||||
- kafka2
|
- kafka2
|
||||||
- redis
|
- redis
|
||||||
- mysql
|
- mysql
|
||||||
|
external_links:
|
||||||
|
- ${NACOS_CONTAINER_NAME}
|
||||||
ports:
|
ports:
|
||||||
- ${GNS_EXECUTOR_LOCAL_PORT}:8083
|
- ${GNS_EXECUTOR_LOCAL_PORT}:8083
|
||||||
restart: always
|
restart: always
|
||||||
|
|
@ -172,10 +184,11 @@ services:
|
||||||
networks:
|
networks:
|
||||||
gitlink_network:
|
gitlink_network:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
name: gitlink_network
|
|
||||||
driver_opts:
|
driver_opts:
|
||||||
com.docker.network.enable_ipv6: "true"
|
com.docker.network.enable_ipv6: "true"
|
||||||
|
microservices_network:
|
||||||
|
external:
|
||||||
|
name: ${NACOS_NETWORK_NAME}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,4 @@ FROM openjdk:11.0.12-jre-slim
|
||||||
COPY writer/target/gns-writer-1.0.0.jar /data/gns-writer-app.jar
|
COPY writer/target/gns-writer-1.0.0.jar /data/gns-writer-app.jar
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
EXPOSE 8082
|
EXPOSE 8082
|
||||||
ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS gns-writer-app.jar"]
|
ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS gns-writer-app.jar $NACOS_OPTS"]
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<includeSystemScope>true</includeSystemScope>
|
<includeSystemScope>true</includeSystemScope>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
@ -35,24 +36,26 @@
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- mybatis-plus begin -->
|
<!-- mybatis-plus begin -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.5.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>mybatis-plus</artifactId>
|
<artifactId>mybatis-plus</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.5.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- mybatis-plus end -->
|
<!-- mybatis-plus end -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
<version>5.1.38</version>
|
<version>8.0.31</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|
@ -75,7 +78,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<version>2.3.4.RELEASE</version>
|
<version>${springboot.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
package cn.org.gitlink.notification.model.config;
|
package cn.org.gitlink.notification.model.config;
|
||||||
|
|
||||||
import cn.org.gitlink.notification.model.handler.MetaHandler;
|
import cn.org.gitlink.notification.model.handler.MetaHandler;
|
||||||
|
import com.baomidou.mybatisplus.annotation.DbType;
|
||||||
import com.baomidou.mybatisplus.core.config.GlobalConfig;
|
import com.baomidou.mybatisplus.core.config.GlobalConfig;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
@ -13,13 +15,28 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
@MapperScan("cn.org.gitlink.notification.model.dao")
|
@MapperScan("cn.org.gitlink.notification.model.dao")
|
||||||
public class MyBatisPlusConfig {
|
public class MyBatisPlusConfig {
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 分页插件
|
||||||
|
// */
|
||||||
|
// @Bean
|
||||||
|
// public PaginationInnerInterceptor paginationInterceptor() {
|
||||||
|
// PaginationInnerInterceptor paginationInterceptor = new PaginationInnerInterceptor();
|
||||||
|
// return paginationInterceptor;
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页插件
|
* 分页插件
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public PaginationInterceptor paginationInterceptor() {
|
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||||
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||||
return paginationInterceptor;
|
PaginationInnerInterceptor paginationInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
|
||||||
|
// 配置分页参数
|
||||||
|
paginationInterceptor.setMaxLimit(500L);
|
||||||
|
// 设置分页参数的封装方式,默认为false,即不封装分页参数
|
||||||
|
paginationInterceptor.setOverflow(false);
|
||||||
|
interceptor.addInnerInterceptor(paginationInterceptor);
|
||||||
|
return interceptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
34
pom.xml
34
pom.xml
|
|
@ -26,30 +26,26 @@
|
||||||
<skipTests>true</skipTests>
|
<skipTests>true</skipTests>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<springboot.version>2.3.4.RELEASE</springboot.version>
|
<!-- <springboot.version>2.3.12.RELEASE</springboot.version>-->
|
||||||
|
<springboot.version>2.7.7</springboot.version>
|
||||||
|
<spring-boot.version>2.7.7</spring-boot.version>
|
||||||
|
<spring-cloud.version>2021.0.5</spring-cloud.version>
|
||||||
|
<spring-cloud-alibaba.version>2021.0.4.0</spring-cloud-alibaba.version>
|
||||||
|
<swagger.fox.version>3.0.0</swagger.fox.version>
|
||||||
|
<knife4j-spring-ui.version>3.0.3</knife4j-spring-ui.version>
|
||||||
|
<knife4j-spring-boot-starter.version>3.0.3</knife4j-spring-boot-starter.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
|
<version>${swagger.fox.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-swagger2</artifactId>
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
<version>2.9.2</version>
|
<version>${swagger.fox.version}</version>
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
|
||||||
<artifactId>swagger-bootstrap-ui</artifactId>
|
|
||||||
<version>1.9.6</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
|
||||||
<artifactId>knife4j-discovery-spring-boot-starter</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
|
||||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
|
||||||
<version>2.0.5</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
|
|
@ -59,7 +55,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>3.10</version>
|
<version>3.12.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,41 @@
|
||||||
<artifactId>gns-model</artifactId>
|
<artifactId>gns-model</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
<version>${spring-cloud-alibaba.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
<version>${spring-cloud-alibaba.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
<version>${springboot.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Swagger -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
<version>${swagger.fox.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- knife4j -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||||
|
<version>${knife4j-spring-boot-starter.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.validation</groupId>
|
||||||
|
<artifactId>validation-api</artifactId>
|
||||||
|
<version>2.0.1.Final</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
@ -37,6 +72,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,14 @@ package cn.org.gitlink.notification.reader;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
@ComponentScan("cn.org.gitlink.notification.*")
|
@ComponentScan("cn.org.gitlink.notification.*")
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
|
@EnableDiscoveryClient
|
||||||
public class ReaderApiApplication {
|
public class ReaderApiApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(ReaderApiApplication.class, args);
|
SpringApplication.run(ReaderApiApplication.class, args);
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,7 @@ package cn.org.gitlink.notification.reader.config;
|
||||||
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
|
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
|
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
import springfox.documentation.builders.PathSelectors;
|
import springfox.documentation.builders.PathSelectors;
|
||||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
|
@ -15,6 +14,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableSwagger2
|
@EnableSwagger2
|
||||||
|
@EnableWebMvc
|
||||||
@EnableKnife4j
|
@EnableKnife4j
|
||||||
public class SwaggerConfig {
|
public class SwaggerConfig {
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,24 @@ logging:
|
||||||
config: classpath:logback.xml
|
config: classpath:logback.xml
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: microservices-gns-reader
|
||||||
|
mvc:
|
||||||
|
pathmatch:
|
||||||
|
matching-strategy: ant_path_matcher
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: ${nacos_ip}:${nacos_port}
|
||||||
|
username: ${nacos_username}
|
||||||
|
password: ${nacos_password}
|
||||||
|
config:
|
||||||
|
# 配置中心地址
|
||||||
|
server-addr: ${nacos_ip}:${nacos_port}
|
||||||
|
username: ${nacos_username}
|
||||||
|
password: ${nacos_password}
|
||||||
redis:
|
redis:
|
||||||
database: 0
|
database: 0
|
||||||
host: redis
|
host: redis
|
||||||
|
|
@ -19,7 +36,7 @@ spring:
|
||||||
timeout: 1000
|
timeout: 1000
|
||||||
|
|
||||||
datasource:
|
datasource:
|
||||||
driver-class-name: com.mysql.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://mysql:3306/gitlink_notification?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8&allowMultiQueries=true&useSSL=false
|
url: jdbc:mysql://mysql:3306/gitlink_notification?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8&allowMultiQueries=true&useSSL=false
|
||||||
username: gitlink
|
username: gitlink
|
||||||
password: giTlinK0^827
|
password: giTlinK0^827
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,39 @@
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
<version>${spring-cloud-alibaba.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
<version>${spring-cloud-alibaba.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
<version>${springboot.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Swagger -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
<version>${swagger.fox.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- knife4j -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||||
|
<version>${knife4j-spring-boot-starter.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.validation</groupId>
|
||||||
|
<artifactId>validation-api</artifactId>
|
||||||
|
<version>2.0.1.Final</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
@ -39,6 +72,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,14 @@ package cn.org.gitlink.notification;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
@ComponentScan("cn.org.gitlink.notification.*")
|
@ComponentScan("cn.org.gitlink.notification.*")
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
|
@EnableDiscoveryClient
|
||||||
public class WriterApiApplication {
|
public class WriterApiApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(WriterApiApplication.class, args);
|
SpringApplication.run(WriterApiApplication.class, args);
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,24 @@ logging:
|
||||||
config: classpath:logback.xml
|
config: classpath:logback.xml
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: microservices-gns-writer
|
||||||
|
mvc:
|
||||||
|
pathmatch:
|
||||||
|
matching-strategy: ant_path_matcher
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: ${nacos_ip}:${nacos_port}
|
||||||
|
username: ${nacos_username}
|
||||||
|
password: ${nacos_password}
|
||||||
|
config:
|
||||||
|
# 配置中心地址
|
||||||
|
server-addr: ${nacos_ip}:${nacos_port}
|
||||||
|
username: ${nacos_username}
|
||||||
|
password: ${nacos_password}
|
||||||
kafka:
|
kafka:
|
||||||
producer:
|
producer:
|
||||||
bootstrap_servers: kafka1:9092,kafka2:9092
|
bootstrap_servers: kafka1:9092,kafka2:9092
|
||||||
|
|
@ -30,7 +48,7 @@ spring:
|
||||||
timeout: 1000
|
timeout: 1000
|
||||||
|
|
||||||
datasource:
|
datasource:
|
||||||
driver-class-name: com.mysql.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://mysql:3306/gitlink_notification?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8&allowMultiQueries=true&useSSL=false
|
url: jdbc:mysql://mysql:3306/gitlink_notification?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8&allowMultiQueries=true&useSSL=false
|
||||||
username: gitlink
|
username: gitlink
|
||||||
password: giTlinK0^827
|
password: giTlinK0^827
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue