mirror of
https://gitee.com/yudaocode/SpringBoot-Labs.git
synced 2026-09-03 05:53:54 +08:00
增加 Consul 入门
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
# rocketmq 配置项,对应 RocketMQProperties 配置类
|
||||
rocketmq:
|
||||
name-server: 127.0.0.1:9876 # RocketMQ Namesrv
|
||||
|
||||
server:
|
||||
port: 8081
|
||||
@@ -3,20 +3,19 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>labx-12</artifactId>
|
||||
<artifactId>labx-29</artifactId>
|
||||
<groupId>cn.iocoder.springboot.labs</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>labx-20-sc-config-server-git-auto-refresh-by-bus</artifactId>
|
||||
<artifactId>labx-29-sc-config-server-git-auto-refresh-by-bus</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<spring.boot.version>2.2.4.RELEASE</spring.boot.version>
|
||||
<spring.cloud.version>Hoxton.SR1</spring.cloud.version>
|
||||
<spring.cloud.alibaba.version>2.2.0.RELEASE</spring.cloud.alibaba.version>
|
||||
</properties>
|
||||
|
||||
<!--
|
||||
@@ -39,13 +38,6 @@
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||
<version>${spring.cloud.alibaba.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
@@ -62,10 +54,10 @@
|
||||
<artifactId>spring-cloud-config-server</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 引入基于 RocketMQ 的 Spring Cloud Bus 的实现的依赖,并实现对其的自动配置 -->
|
||||
<!-- 引入基于 Consul 的 Spring Cloud Bus 的实现的依赖,并实现对其的自动配置 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bus-rocketmq</artifactId>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-consul-bus</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 引入 Spring Cloud Config Monitor 依赖,提供 `/monitor` 接口,用于刷新配置 -->
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.springcloud.labx20.configserverdemo;
|
||||
package cn.iocoder.springcloud.labx29.configserverdemo;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@@ -19,6 +19,7 @@ spring:
|
||||
# username: ${CODING_USERNAME} # 账号
|
||||
# password: ${CODING_PASSWORD} # 密码
|
||||
|
||||
# rocketmq 配置项,对应 RocketMQProperties 配置类
|
||||
rocketmq:
|
||||
name-server: 127.0.0.1:9876 # RocketMQ Namesrv
|
||||
# Consul
|
||||
consul:
|
||||
host: 127.0.0.1
|
||||
port: 8500
|
||||
@@ -3,20 +3,19 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>labx-12</artifactId>
|
||||
<artifactId>labx-29</artifactId>
|
||||
<groupId>cn.iocoder.springboot.labs</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>labx-20-sc-config-user-application-auto-refresh-by-bus</artifactId>
|
||||
<artifactId>labx-29-sc-config-user-application-auto-refresh-by-bus</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<spring.boot.version>2.2.4.RELEASE</spring.boot.version>
|
||||
<spring.cloud.version>Hoxton.SR1</spring.cloud.version>
|
||||
<spring.cloud.alibaba.version>2.2.0.RELEASE</spring.cloud.alibaba.version>
|
||||
</properties>
|
||||
|
||||
<!--
|
||||
@@ -39,13 +38,6 @@
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||
<version>${spring.cloud.alibaba.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
@@ -62,10 +54,10 @@
|
||||
<artifactId>spring-cloud-starter-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 引入基于 RocketMQ 的 Spring Cloud Bus 的实现的依赖,并实现对其的自动配置 -->
|
||||
<!-- 引入基于 Consul 的 Spring Cloud Bus 的实现的依赖,并实现对其的自动配置 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bus-rocketmq</artifactId>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-consul-bus</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.springcloud.labx20.userapplication;
|
||||
package cn.iocoder.springcloud.labx29.userapplication;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.springcloud.labx20.userapplication.config;
|
||||
package cn.iocoder.springcloud.labx29.userapplication.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.iocoder.springcloud.labx20.userapplication.controller;
|
||||
package cn.iocoder.springcloud.labx29.userapplication.controller;
|
||||
|
||||
import cn.iocoder.springcloud.labx20.userapplication.config.OrderProperties;
|
||||
import cn.iocoder.springcloud.labx29.userapplication.config.OrderProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
@@ -0,0 +1,9 @@
|
||||
spring:
|
||||
cloud:
|
||||
# Consul
|
||||
consul:
|
||||
host: 127.0.0.1
|
||||
port: 8500
|
||||
|
||||
server:
|
||||
port: 8081
|
||||
@@ -15,6 +15,9 @@
|
||||
<module>labx-29-sc-bus-consul-demo-publisher</module>
|
||||
<module>labx-29-sc-bus-consul-demo-listener</module>
|
||||
<module>labx-29-sc-bus-consul-demo-listener-actuator</module>
|
||||
|
||||
<module>labx-29-sc-config-server-git-auto-refresh-by-bus</module>
|
||||
<module>labx-29-sc-config-user-application-auto-refresh-by-bus</module>
|
||||
</modules>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user