my-csc-config-file.git 5 年之前
父节点
当前提交
095998d553
共有 3 个文件被更改,包括 92 次插入0 次删除
  1. 36 0
      pom.xml
  2. 21 0
      src/main/java/com/unissoft/ConfigStart.java
  3. 35 0
      src/main/resources/application.yml

+ 36 - 0
pom.xml

@@ -0,0 +1,36 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0"
3
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
+    <parent>
6
+        <artifactId>csc-szls-parent</artifactId>
7
+        <groupId>com.unissoft</groupId>
8
+        <version>1.0-SNAPSHOT</version>
9
+        <relativePath>../csc-szls-parent/pom.xml</relativePath>
10
+    </parent>
11
+    <modelVersion>4.0.0</modelVersion>
12
+
13
+    <artifactId>csc-szls-config-server</artifactId>
14
+    <description>配置中心服务</description>
15
+
16
+    <dependencies>
17
+        <dependency>
18
+            <groupId>org.springframework.cloud</groupId>
19
+            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
20
+        </dependency>
21
+        <!-- spring cloud config 服务端包 -->
22
+        <dependency>
23
+            <groupId>org.springframework.cloud</groupId>
24
+            <artifactId>spring-cloud-config-server</artifactId>
25
+        </dependency>
26
+
27
+        <dependency>
28
+            <groupId>org.springframework.cloud</groupId>
29
+            <artifactId>spring-cloud-starter-bus-amqp</artifactId>
30
+        </dependency>
31
+        <dependency>
32
+            <groupId>org.springframework.boot</groupId>
33
+            <artifactId>spring-boot-starter-actuator</artifactId>
34
+        </dependency>
35
+    </dependencies>
36
+</project>

+ 21 - 0
src/main/java/com/unissoft/ConfigStart.java

@@ -0,0 +1,21 @@
1
+package com.unissoft;
2
+
3
+import org.springframework.boot.SpringApplication;
4
+import org.springframework.boot.autoconfigure.SpringBootApplication;
5
+import org.springframework.cloud.config.server.EnableConfigServer;
6
+import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
7
+
8
+/**
9
+ * 文件描述
10
+ *
11
+ * @author tongxi.xia
12
+ * @date 2020年11月18日 11:27
13
+ */
14
+
15
+@SpringBootApplication
16
+@EnableConfigServer //开启配置中心功能
17
+public class ConfigStart {
18
+    public static void main(String[] args) {
19
+        SpringApplication.run(ConfigStart.class, args);
20
+    }
21
+}

+ 35 - 0
src/main/resources/application.yml

@@ -0,0 +1,35 @@
1
+#端口号
2
+server:
3
+  port: 9604
4
+
5
+eureka:
6
+  instance:
7
+    hostname: localhost #地址
8
+    prefer-ip-address: true
9
+  client:
10
+    service-url:
11
+      # 向注册中心注册服务
12
+      defaultZone: http://${eureka.instance.hostname}:9600/eureka
13
+
14
+spring:
15
+  application:
16
+    name: csc-szls-config
17
+  cloud:
18
+    config:
19
+      server:
20
+        git:
21
+          uri: http://admin@172.16.0.46:1000/r/csc-szls-config.git  # 远程git仓库的地址
22
+          username: admin  # 以及相应的账户名
23
+          password: admin  # 和密码
24
+#          basedir: E:\JWT\csc-szls-config\  # 可以使用这个配置项来指定本地git仓库的路径
25
+          default-label: master
26
+          search-paths:
27
+          - config-repo # 指定搜索根路径下的所有目录,若有多个路径使用逗号隔开
28
+      # 分支
29
+      label: master
30
+  # 配置rabbitmq的地址以及用户密码
31
+  rabbitmq:
32
+    host: 172.16.0.46
33
+    port: 5672
34
+    username: admin
35
+    password: admin