实战springcloud alibaba

实战springcloud alibaba

前言

如何搭建一套最新的springcloud alibaba,以适配项目升级需求?
1.版本的选择
2.各组件的适配
3.新技术的敏感性
4.前瞻性,几年内不会被淘汰
参考资料:Spring Cloud Alibaba 参考文档 https://spring-cloud-alibaba-group.github.io/github-pages/2022/zh-cn/2022.0.0.0-RC2.html

一、版本介绍

springcloudspringbootspringcloudalibaba持久层框架注册中心/配置中心熔断、限流数据库缓存/分布式锁数据库连接池远程调用分布式事务消息队列定时任务大数据存储文档生成链路追踪服务监控
2023.0.33.3.52023.0.1.2mybatis-flex1.10.9nacos2023.0.1.2(nacos服务端使用2.3.2)sentinel2023.0.1.2(dashboard使用1.8.8)mysql8redis德鲁伊 druidopen-feignseatakafkaxxl-job2.5.0elasticsearch7.9.3springdoc-openapi-starter-webmvc-uiSky walkingpromothus+grafana

二、组件nacos作注册中心、配置中心

2.1 导入包
 <dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId></dependency>

这里的版本与springcloud alibaba一致:2023.0.1.2

2.2 配置yml(bootstrap.yml优先级高,所以配置nacos的连接写在bootstrap.yml)
spring:application:# 应用名称name: mfcx-admin-serviceprofiles:# 环境配置active: devcloud:nacos:discovery:# 服务注册地址server-addr: 192.168.174.192:8848#        namespace: dev # 命名空间。这里使用 dev 开发环境group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUPconfig:# 配置中心地址server-addr: 192.168.174.192:8848#        namespace: dev # 命名空间。这里使用 dev 开发环境group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP# 配置文件格式file-extension: yaml# 共享配置shared-configs:- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}extension-configs:- data-id: mfcx-admin-service-bak-info.yamlgroup: DEFAULT_GROUPrefresh: true

如上: 没有配置那么space,那么使用的是public,分组用的是DEFAULT_GROUP。
配置文件:
1、会读取默认的nacos配置文件名,文件如下:${spring.application.name}-${spring.profile.active}.${spring.cloud.nacos.config.file-extension}
例如,我的配置文件名为: mfcx-admin-service-dev.yaml
2、共享配置,即每个微服务都可以读取到:application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
例如:application-dev.yaml
3、延伸配置,即extension-configs指定的文件名 mfcx-admin-service-bak-info.yaml

2.3 注解

主启动类加上注解 @EnableDiscoveryClient

三、网关gateway

官网:https://docs.spring.io/spring-cloud-gateway/reference/spring-cloud-gateway/gatewayfilter-factories/rewritepath-factory.html

3.1 导入包
 <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-loadbalancer</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bootstrap</artifactId></dependency>

注:
1.网关引入的是spring-cloud-starter-gateway,而非spring-boot-starter-web
2.在SpringCloud 2020.* 以后版本把 bootstrap 禁用了,导致在读取文件的时候读取不到而报错,所以我们只要把 spring-cloud-starter-bootstrap重新导入进来就会生效了
3.Spring Cloud 2020 版本后移除了 Netflix Ribbon,spring-cloud-starter-loadbalancer 是其官方替代品: 为微服务间的 HTTP/RPC 调用提供 服务实例选择能力,并处理请求的负载均衡逻辑所以网关需引入spring-cloud-loadbalancer
如上使用的版本号分别为:4.1.5、4.1.4、4.1.4

3.2 配置动态路由
spring:cloud:gateway:discovery:locator:lowerCaseServiceId: trueenabled: trueroutes:# 认证中心- id: mfcx-auth-serviceuri: lb://mfcx-auth-servicepredicates:- Path=/auth/**filters:- RewritePath=/auth/(?<segment>.*),/$\{segment}- id: mfcx-admin-serviceuri: lb://mfcx-admin-servicepredicates:- Path=/admin/**filters:#重写路径,例如:localhost:8080/admin/userInfo/queryUserInfoByUserId 在进入/mfcx-admin-service服务后路径为/userInfo/queryUserInfoByUserId- RewritePath=/admin/(?<segment>.*),/$\{segment}

四、文档springdoc-openapi-starter-webmvc-ui

官网https://springdoc.org/#google_vignette

4.1 引入包
 <dependency><groupId>org.springdoc</groupId><artifactId>springdoc-openapi-starter-webmvc-ui</artifactId></dependency>

版本用的 2.6.0

4.2 yml配置
springdoc:api-docs:enabled: truepath: /v3/api-docsswagger-ui:path: /swagger-ui.htmlenabled: true
4.3 写配置类,可以分模块(每个类一个模块,可以理解为每个controller一个bean)
@Configuration
public class Swagger3Config {/*** 这里配置多模块,即每个控制器为一个分类,也可以不配置下面的Bean,那么就是该微服务所有接口都在一起**/@Beanpublic GroupedOpenApi UserApi() {return GroupedOpenApi.builder().group("系统用户模块").pathsToMatch("/userInfo/**").build();}@Beanpublic GroupedOpenApi RoleApi() {return GroupedOpenApi.builder().group("系统角色模块").pathsToMatch("/roleInfo/**", "/others").build();}/*@Beanpublic GroupedOpenApi CustomerApi(){return GroupedOpenApi.builder().group("客户微服务模块").pathsToMatch("/customer/**","/customers").build();}*/@Beanpublic OpenAPI docsOpenApi() {return new OpenAPI().info(new Info().title("神雕出行").description("通用设计rest").version("v1.0")).externalDocs(new ExternalDocumentation().description("www.123.com").url("https://www.baidu.com/"));}
}
4.4 注解

在类上面:@Tag(name = "登录接口")
在方法上面:@Operation(summary = "登录")
在字段或属性类上面:@Schema(description = "用户名")

五、远程调用:open-feign的使用

官网: https://docs.spring.io/spring-cloud-openfeign/reference/spring-cloud-openfeign.html

5.1 消费方引入包
  <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId></dependency>

版本号是4.1.3

5.2 标注解

消费方主启动类标注解 @EnableFeignClients(basePackages = “com.mfcx.cloud.feign”)

注意这里的feign接口在其他模块api,这里需要指定包路径

5.3 feign接口的编写
@FeignClient(value = "mfcx-auth-service",path = "/remote/auth",//  configuration = FeignConfiguration.class,fallback = AuthApiFeignClientCallBack.class)
public interface AuthApiFeignClient {@PostMapping("/queryGoodsDetail")List<GoodsDetailVO> queryGoodsDetail();
}

注:这里的value =
“mfcx-auth-service"与服务方的微服务名称一致,path的路径与feign接口的实现类上的注解@RequestMapping(”/remote/auth")一致

5.4 超时机制
spring:cloud:openfeign:client:config:#全局超时配置default:# 连接超时时间 3秒connectTimeout: 3000# 读取超时时间 3秒readTimeout: 3000# mfcx-auth-service 服务的超时时间(他会覆盖全局配置)mfcx-auth-service:connectTimeout: 5000readTimeout: 5000
5.5 设置重试机制
@Configuration
public class FeignConfig {@Beanpublic Retryer retryer() {// 重试间隔时间,重试最大时间,最大重试次数(初始1次,重试2次)return new Retryer.Default(1000, 1000, 3);}
}

注:这里配置的是feign调用失败,允许再次尝试的参数

5.6 使用http client5 替换http,大幅提升性能

引入包

 <dependency><groupId>org.apache.httpcomponents.client5</groupId><artifactId>httpclient5</artifactId></dependency><dependency><groupId>io.github.openfeign</groupId><artifactId>feign-hc5</artifactId></dependency>

修改配置

spring:cloud:openfeign:#使用HttpClient5  替换http,参考官网:https://docs.spring.io/spring-cloud-openfeign/reference/spring-cloud-openfeign.htmlhttpclient:hc5:enabled: trueclient:config:# openfeign全局超时时间配置default:# 连接超时时间 3秒connectTimeout: 3000# 读取超时时间 3秒readTimeout: 3000# mfcx-auth-service 服务的超时时间(他会覆盖全局配置)mfcx-auth-service:connectTimeout: 5000readTimeout: 5000
5.7 对请求和响应进行GZIP压缩

对请求和响应进行GZIP压缩
Spring Cloud OpenFeign支持对请求和响应进行GZIP压缩,以减少通信过程中的性能损耗。
通过下面的两个参数设置,就能开启请求与相应的压缩功能:
开启请求压缩: spring.cloud.openfeign.compression.request.enabled=true
压缩的数据类型: spring.cloud.openfeign.compression.request.mime-types=text/xml,application/xml,application/json
触发压缩的大小: spring.cloud.openfeign.compression.request.min-request-size=2048
开启返回压缩 : spring.cloud.openfeign.compression.response.enabled=true

5.8 打印feign日志

配置类加一个Bean

@Configuration
public class FeignConfig {@Beanpublic Retryer retryer() {// 重试间隔时间,重试最大时间,最大重试次数(初始1次,重试2次)return new Retryer.Default(1000, 1000, 3);}//feign 提供了日志打印功能,我们可以通过配置来调整日志级别,//从而了解 Feign 中 Http 请求的细节,//说白了就是对Feign接口的调用情况进行监控和输出@Beanpublic Logger.Level logLevel() {return Logger.Level.FULL;}
}

yml配置

logging:level:com:mfcx:cloud:feign:AuthApiFeignClient: debug

注: 其中com.mfcx.cloud.feign.AuthApiFeignClient是接口(标记@FeignClient的接口),配置了日志,能清楚的看到远程调用的重试次数及失败原因

六、服务降级 sentinel

中文官网 : https://sentinelguard.io/zh-cn/docs/quick-start.html

6.1 导包
     <dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-sentinel</artifactId></dependency>
6.2 yml配置

服务端连接sentinel大盘

spring:sentinel:transport:dashboard: localhost:8080 #配置Sentinel dashboard控制台服务地址port: 8719 #默认8719端口,假如被占用会自动从8719开始依次+1扫描,直至找到未被占用的端口

消费端激活Sentinel对Feign的支持

feign:sentinel:enabled: true
6.3 feign接口配置回退类,AuthApiFeignClientCallBack
@FeignClient(value = "mfcx-auth-service",path = "/remote/auth",fallbackFactory = AuthApiFeignClientCallback.class)
public interface AuthApiFeignClient {@PostMapping("/queryUserInfo")List<UserInfoResDTO> queryUserInfo(@RequestBody UserInfoReqDTO userInfo);@PostMapping("/queryUser")UserInfoResDTO queryUser();@PostMapping("/queryUserByname")CommonResult<List<UserInfoResDTO>> queryUserByName(@RequestBody UserInfoReqDTO userInfo);
}
6.4 编写回退类AuthApiFeignClientCallBack
@Component
@Slf4j
public class AuthApiFeignClientCallback implements FallbackFactory<AuthApiFeignClient> {@Overridepublic AuthApiFeignClient create(Throwable cause) {return new AuthApiFeignClient() {@Overridepublic List<UserInfoResDTO> queryUserInfo(UserInfoReqDTO userInfo) {log.error("[Fallback] 调用 mfcx-auth-service queryUserInfo失败,原因:{}", cause.getMessage());return List.of();}@Overridepublic UserInfoResDTO queryUser() {log.error("[Fallback] 调用 mfcx-auth-service queryUser失败,原因:{}", cause.getMessage());return new UserInfoResDTO();}@Overridepublic CommonResult queryUserByName(UserInfoReqDTO userInfo) {log.error("[Fallback] 调用 mfcx-auth-service queryUser失败,原因:{}", cause.getMessage());CommonResult result = CommonResult.error(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR);return result;}};}
}
6.5 显示声明回退类

因为AuthApiFeignClientCallBack 位于 mfcx-auth-api 模块,在消费方需要显示声明此对象

@Configuration
public class FeignConfig {@Beanpublic Retryer retryer() {// 重试间隔时间,重试最大时间,最大重试次数(初始1次,重试2次)return new Retryer.Default(1000, 1000, 3);}//feign 提供了日志打印功能,我们可以通过配置来调整日志级别,//从而了解 Feign 中 Http 请求的细节,//说白了就是对Feign接口的调用情况进行监控和输出@Beanpublic Logger.Level logLevel() {return Logger.Level.FULL;}/*** 显式声明回退工厂 Bean* @return*/@Beanpublic AuthApiFeignClientCallBack authApiFeignClientCallBack() {return new AuthApiFeignClientCallBack();}
}

七、sentinel实现网关限流

网关限流:
https://github.com/alibaba/Sentinel/wiki/%E7%BD%91%E5%85%B3%E9%99%90%E6%B5%81#spring-cloud-gateway

这里采用gateway+nacos+sentinel实现网关动态限流

7.1 引包
   <dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-sentinel</artifactId></dependency><!-- SpringCloud Alibaba Sentinel Gateway --><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId></dependency><!-- Sentinel Datasource Nacos --><dependency><groupId>com.alibaba.csp</groupId><artifactId>sentinel-datasource-nacos</artifactId></dependency>
7.2 主启动类加一行代码,添加此代码,在Sentinel控制台中做判断使用
System.setProperty("csp.sentinel.app.type", "1");
7.3 添加yml配置
spring:cloud:sentinel:transport:dashboard: 192.168.10.181:8858port: 8719eager: truedatasource:ds1:nacos:# nacos地址server-addr: 192.168.10.181:8848# 配置文件名data-id: gateway-flow-rule-sentinel# 分组group-id: DEFAULT_GROUP# 类型data-type: json# 固定,网关流控rule-type: gw-flow#命名空间namespace: 0b911c8b-a723-4af0-a4d0-9fa7c0a579bbds2:nacos:server-addr: 192.168.10.181:8848data-id: gateway-flow-rule-api-sentinelgroup-id: DEFAULT_GROUPdata-type: json# 固定,分组流控rule-type: gw-api-group
7.4 写两个配置类

加载nacos中的限流数据配置类

@Slf4j
@Configuration
public class GatewayConfiguration {@Value("${spring.cloud.nacos.config.server-addr}")private String nacosAddr;@Value("${spring.cloud.nacos.config.group}")private String group;private final List<ViewResolver> viewResolvers;private final ServerCodecConfigurer serverCodecConfigurer;public GatewayConfiguration(ObjectProvider<List<ViewResolver>> viewResolversProvider,ServerCodecConfigurer serverCodecConfigurer) {this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);this.serverCodecConfigurer = serverCodecConfigurer;}@Bean@Order(Ordered.HIGHEST_PRECEDENCE)public SentinelGatewayBlockExceptionHandler sentinelGatewayBlockExceptionHandler() {// Register the block exception handler for Spring Cloud Gateway.return new SentinelGatewayBlockExceptionHandler(viewResolvers, serverCodecConfigurer);}@PostConstructpublic void doInit() {// 注册 API 分组规则ReadableDataSource<String, Set<ApiDefinition>> apiDefinitionSource =new NacosDataSource<>(nacosAddr,group,"gateway-flow-rule-api-sentinel",source -> JSON.parseObject(source, new TypeReference<>() {}));GatewayApiDefinitionManager.register2Property(apiDefinitionSource.getProperty());// 注册网关限流规则ReadableDataSource<String, Set<GatewayFlowRule>> flowRuleSource =new NacosDataSource<>(nacosAddr,group,"gateway-flow-rule-sentinel",source -> JSON.parseObject(source, new TypeReference<>() {}));GatewayRuleManager.register2Property(flowRuleSource.getProperty());// 打印当前规则信息Set<GatewayFlowRule> rules = GatewayRuleManager.getRules();System.out.println("限流规则数量:" + rules.size());rules.forEach(rule -> System.out.println("Rule: " + rule));}
//    @Bean
//    @Order(Ordered.HIGHEST_PRECEDENCE)
//    public GlobalFilter sentinelGatewayFilter() {
//        return new SentinelGatewayFilter();
//    }}

限流返回数据格式配置类

@Configuration
public class SentinelGatewayConfig {public SentinelGatewayConfig() {GatewayCallbackManager.setBlockHandler(new BlockRequestHandler() {@Overridepublic Mono<ServerResponse> handleRequest(ServerWebExchange exchange, Throwable t) {// R error = R.error(500, "限流啦 别在试啦");Map<Object,Object> map = new HashMap<>();map.put(500, "限流啦 别在试啦");String errorStr = JSON.toJSONString(map);Mono<ServerResponse> just = ServerResponse.ok().body(Mono.just(errorStr), String.class);return just;}});}
}
7.5 nacos中的配置

文件 gateway-flow-rule-sentinel,格式 json

[{"resource": "mfcx-auth-service","resourceMode": 0,"count": 15,"intervalSec": 60},{"resource": "mfcx-auth-service-api","resourceMode": 1,"count": 4,"intervalSec": 60},{"resource": "mfcx-admin-service-api","resourceMode": 1,"count": 5,"intervalSec": 60}
]

文件 gateway-flow-rule-api-sentinel ,格式:json

[{"apiName": "mfcx-admin-service-api","predicateItems": [{"pattern": "/admin/feign/user/queryUserInfo"},{"pattern":"/admin/feign/user/queryUser","matchStrategy": 0}]
}]

含义解释:

resource:表示限流的资源名称,这里是针对认证服务整体进行限流
resourceMode: 0=服务, 1=API, 2=自定义 流控粒度
count: 在统计时间窗口内允许的最大请求数量
intervalSec:统计时间窗口长度(秒)
apiName:定义这组路由规则的名称标识,与resourceMode为1 的resource对应
predicateItems: 路由断言规则数组,定义匹配请求路径的规则集合,决定哪些请求路径会被路由到目标分组
pattern:路径匹配
matchStrategy: 0=精确 1=前缀 2=正则 3=包含,默认为0

八、引入mybatis-flex

mybatis-flex官网: https://mybatis-flex.com/

8.1 导包
  <!--数据库相关--><dependency><groupId>com.mybatis-flex</groupId><artifactId>mybatis-flex-spring-boot3-starter</artifactId></dependency><dependency><groupId>com.mybatis-flex</groupId><artifactId>mybatis-flex-processor</artifactId></dependency><dependency><groupId>com.mysql</groupId><artifactId>mysql-connector-j</artifactId></dependency><!--其中包含mybatis-spring-boot-starter--><dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId><exclusions><!-- 保留 mybatis-spring-boot-starter 但排除特定传递依赖 --><exclusion><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId></exclusion><exclusion><groupId>org.mybatis</groupId><artifactId>mybatis-spring</artifactId></exclusion></exclusions></dependency>

其中的版本号一次是:1.10.9、1.10.9、8.3.0、2.1.0

8.2 引入数据库相关配置
spring:datasource:username: rootpassword: 123456url: jdbc:mysql://192.168.174.192:3307/tfx_user?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghaidriver-class-name: com.mysql.cj.jdbc.Drivermybatis-flex:mapper-locations: classpath*:/mapper/**/*.xmlconfiguration:map-underscore-to-camel-case: true

至此,mybatis-flex就引入了项目。
Mapper层的写法,

@Mapper
public interface UserInfoMapper extends BaseMapper<UserInfo> {
}

实体类的写法

@Data
@Table("user_info")
public class UserInfo {//雪花算法自动生成主键@Id(keyType = KeyType.Generator,value = KeyGenerators.snowFlakeId)private Long id;private String name;private String addr;private Long roleId;
}

九、分布式事务seata

seata的详细引入过程

十、 服务监控

这里使用springboot Admin做服务监控,且集成nacos

服务端:

10.1、创建微服务 xxx-monitor-service,pom如下
 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!-- SpringCloud Alibaba Nacos --><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency><!-- SpringCloud Alibaba Nacos Config --><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId></dependency><!--spring-boot-admin使用服务包--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>de.codecentric</groupId><artifactId>spring-boot-admin-starter-server</artifactId></dependency><!--需要密码验证包--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId></dependency><!--在SpringCloud 2020.* 以后版本把 bootstrap 禁用了,导致在读取文件的时候读取不到而报错,所以我们只要把 bootstrap 从新导入进来就会生效了--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bootstrap</artifactId></dependency>
10.2、yml配置:(连接nacos的配置不在这里展示)
spring:security:basic:enabled: trueuser:name: mfcxpassword: mfcxboot:admin:client:url: http://localhost:8091
management:server:port: 8109endpoints:web:exposure:# 从技术上更改端点的暴露 -- 通过HTTP公开所有的端点,可通过 /actuator/{ID} 去查看,如 /actuator/beansinclude: "*"base-path: /actuatorjmx:exposure:include: "*"endpoint:health:show-details: alwayshttptrace:enabled: truemetrics:enabled: true
10.3、写一个配置文件类
@EnableWebSecurity
@Configuration
public class WebSecurityConfigurer {private final String adminContextPath;public WebSecurityConfigurer(AdminServerProperties adminServerProperties) {this.adminContextPath = adminServerProperties.getContextPath();}@Beanpublic SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception {SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();successHandler.setTargetUrlParameter("redirectTo");successHandler.setDefaultTargetUrl(adminContextPath + "/");return httpSecurity.headers((header) -> header.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable)).authorizeHttpRequests((authorize) -> authorize.requestMatchers(adminContextPath + "/assets/**",adminContextPath + "/login",adminContextPath + "/actuator/**",adminContextPath + "/instances/**").permitAll().anyRequest().authenticated()).formLogin((formLogin) -> formLogin.loginPage(adminContextPath + "/login").successHandler(successHandler)).logout((logout) -> logout.logoutUrl(adminContextPath + "/logout")).httpBasic(Customizer.withDefaults()).csrf(AbstractHttpConfigurer::disable).build();}
}
10.4、主启动类记得加注解
@EnableDiscoveryClient
@EnableAdminServer

客户端

10.5、pom配置
 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>
10.6、yml配置
management:server:port: 8099endpoints:web:exposure:# 从技术上更改端点的暴露 -- 通过HTTP公开所有的端点,可通过 /actuator/{ID} 去查看,如 /actuator/beansinclude: "*"base-path: /actuatorjmx:exposure:include: "*"endpoint:health:show-details: alwayshttptrace:enabled: truemetrics:enabled: true
spring:boot:admin:client:#连接监控服务端的地址,也就是actuator的服务端的运行ip 端口url: http://localhost:8091

启动后访问服务端:localhost:8091
可以看到个微服务的注册情况

避坑指南:

客户端不要引入spring-boot-admin-starter-client Nacos 默认会向注册中心上报实例,而 Spring Boot Admin Client 也会主动向 Admin Server 注册,导致同一个应用被注册两次(一次通过 Nacos 间接注册,一次通过 Client 直接注册)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/80430.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

泰迪杯特等奖案例学习资料:基于卷积神经网络与集成学习的网络问政平台留言文本挖掘与分析

(第八届“泰迪杯”数据挖掘挑战赛A题特等奖案例深度解析) 一、案例背景与核心挑战 1.1 应用场景与行业痛点 随着“互联网+政务”的推进,网络问政平台成为政府与民众沟通的重要渠道。某市问政平台日均接收留言超5000条,涉及民生、环保、交通等20余类诉求。然而,传统人工…

DVWA靶场保姆级通关教程--06不安全验证机制

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 目录 文章目录 前言 原理详解 1. 前后端验证逻辑不一致 2. 验证码值保存在客户端 3. 验证码可预测或重复 4. 验证码验证与逻辑解耦 一、处理关卡报错 二、low级别源…

【LeetCode Hot100 | 每日刷题】排序数组

912. 排序数组 - 力扣&#xff08;LeetCode&#xff09; 题目&#xff1a; 给你一个整数数组 nums&#xff0c;请你将该数组升序排列。 你必须在 不使用任何内置函数 的情况下解决问题&#xff0c;时间复杂度为 O(nlog(n))&#xff0c;并且空间复杂度尽可能小。 示例 1&…

Windows系统下使用Kafka和Zookeeper,Python运行kafka(二)

1.配置 Zookeeper 进入解压后的 Zookeeper 目录&#xff08;例如 F:\zookeeper\conf&#xff09;&#xff0c;复制 zoo_sample.cfg 文件并命名为 zoo.cfg&#xff08;如果 zoo.cfg 已经存在&#xff0c;则直接编辑该文件&#xff09;。 打开 zoo.cfg 文件&#xff0c;配置相关…

Web 自动化之 HTML JavaScript 详解

文章目录 一、HTML 常用标签二、javascript 脚本1、什么是 javascript(js)2、 js变量和函数3、js 弹窗处理4、js 流程控制语句和 switch 结构语句应用 一、HTML 常用标签 HTML&#xff1a;超文本标记语言 超文本&#xff1a;不仅只包含文字&#xff0c;还有超链接、视频…这些…

el-date-picker的type为daterange时仅对开始日期做限制

文章目录 前言绣球html代码一、正确代码二、错误代码 前言绣球 需求是这样的&#xff0c;开始日期需要限制只能选择今天的日期&#xff0c;结束日期只能选择今天之后的日期。结束日期很常见&#xff0c;但是单纯限制开始日期&#xff0c;还是蛮少见的&#xff0c;尤其是datera…

观测云:安全、可信赖的监控观测云服务

引言 近日&#xff0c;“TikTok 遭欧盟隐私监管机构调查并处以 5.3 亿欧元”一案&#xff0c;再次引发行业内对数据合规等话题的热议。据了解&#xff0c;仅 2023 年一年就产生了超过 20 亿美元的 GDPR 罚单。这凸显了在全球化背景下&#xff0c;企业在数据隐私保护方面所面临…

认识中间件-以及两个简单的示例

认识中间件-以及两个简单的示例 什么是中间件一个响应处理中间件老朋友 nest g如何使用为某个module引入全局引入编写逻辑一个日志中间件nest g mi 生成引入思考代码进度什么是中间件 官方文档 中间件是在路由处理程序之前调用的函数。中间件函数可以访问请求和响应对象,以及…

基于Flask、Bootstrap及深度学习的水库智能监测分析平台

基于Flask、Bootstrap及深度学习的水库智能监测分析平台 项目介绍 本项目是基于Flask框架构建的水库智能监测分析平台&#xff0c;集水库数据管理、实时监测预警、可视化分析和智能预测功能于一体。 预测水位的预警级别&#xff1a;蓝色预警没有超过正常水位且接近正常水位1米…

springboot生成二维码到海报模板上

springboot生成二维码到海报模板上 QRCodeController package com.ruoyi.web.controller.app;import com.google.zxing.WriterException; import com.ruoyi.app.domain.Opportunity; import com.ruoyi.app.tool.QRCodeGenerator; import com.ruoyi.common.core.page.TableDat…

如何使用极狐GitLab 软件包仓库功能托管 maven?

极狐GitLab 是 GitLab 在中国的发行版&#xff0c;关于中文参考文档和资料有&#xff1a; 极狐GitLab 中文文档极狐GitLab 中文论坛极狐GitLab 官网 软件包库中的 Maven 包 (BASIC ALL) 在项目的软件包库中发布 Maven 产物。然后&#xff0c;在需要将它们用作依赖项时安装它…

企业如何将钉钉付款单高效集成到金蝶云星空?

钉钉数据集成到金蝶云星空&#xff1a;修改下推的付款单③ 在企业信息化系统中&#xff0c;数据的高效流转和准确对接是实现业务流程自动化的关键。本文将分享一个实际案例&#xff0c;展示如何通过轻易云数据集成平台&#xff0c;将钉钉中的付款单数据无缝集成到金蝶云星空系…

python 实现文件批量重命名

以下是使用Python实现文件批量重命名的示例代码。该代码可以将指定目录下的文件按照一定规则进行重命名,这里以将文件重命名为带有编号的文件名为例: import osdef batch_rename(directory):if not os.path.isdir(directory):print(

Pandas学习笔记(四)

DataFrame对象 文章目录 DataFrame对象导入本文需要的包DataFrame与Series的相似之处使用read_csv函数导入DataFrameSeries和DataFrame的共享与专有属性Series和DataFrame的共有方法 对DataFrame进行排序按照单列进行排序按照多列进行排序按照索引进行排序对列索引进行排序 设置…

DA14585墨水屏学习(2)

一、user_svc2_wr_ind_handler函数 void user_svc2_wr_ind_handler(ke_msg_id_t const msgid,struct custs1_val_write_ind const *param,ke_task_id_t const dest_id,ke_task_id_t const src_id) {// sprintf(buf2,"HEX %d :",param->length);arch_printf("…

树莓派5+Ubuntu24.04 LTS串口通信 保姆级教程

【背景】 各位&#xff0c;除了树莓派4B之外&#xff0c;我又搞了个树莓派5, 装的也是Ubuntu24.04 LTS服务器版。装系统的方法跟树莓派4B一样&#xff0c;没什么好说的。装完了系统之后&#xff0c;我就想装个wiringPi来试试串口&#xff0c;却发现这个树莓派5的串口和树莓派4…

【QT】UDP通讯本地调试

qt已经写好了udp通讯代码&#xff0c;现在要进行测试。 1、终端输入ipconfig查看本机网卡的ipv4地址 2、 用udpBind函数&#xff0c;绑定到此ip和自定义的端口号。 3、 打开网络调试助手&#xff0c;自动检测到本机的ip地址&#xff0c;输入任意一个和程序里不一样的端口号。 …

在 Elasticsearch 中连接两个索引

作者&#xff1a;来自 Elastic Kofi Bartlett 解释如何使用 terms query 和 enrich processor 来连接 Elasticsearch 中的两个索引。 更多有关连接两个索引的查询&#xff0c;请参阅文章 “Elastic&#xff1a;开发者上手指南” 中的 “丰富数据及 lookup” 章节。 Elasticsea…

LabVIEW的PID参数自适应控制

在工业控制领域&#xff0c;PID 控制凭借结构简单、稳定性好、工作可靠等优点被广泛应用。然而&#xff0c;传统固定参数的 PID 控制在面对复杂多变的工况时&#xff0c;控制效果往往难以达到最优。基于 LabVIEW 实现 PID 控制根据情况选择参数&#xff08;即参数自适应调整&am…

[redis进阶四]分布式系统之哨兵(2)

目录 一 利用docker搭建环境 板书: 一)准备⼯作: 板书: 解读docker配置文件: 1)安装docker和docker-compose 2) 停⽌之前的redis-server 3) 使⽤docker获取redis镜像 二)编排redis主从节点 板书:​编辑 1) 编写docker-compose.yml 2) 启动所有容器 3) 查看运⾏⽇志 …