spring boot 与spring boot admin整合问题处理
1.在整合springboot admin server时,发现admin client无法注册到admin server上

查找原因后发现代码中报错:HttpMediaTypeNotAcceptableException: Could not find acceptable representation
2.此时知道是返回给admin server类型时发生的错误,但是不知道admin server需要的是什么类型,所以重写WebMvcConfigurer
解析全部类型查看返回类型是什么
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
for (HttpMessageConverter<?> converter : converters) {
if (converter instanceof MappingJackson2HttpMessageConverter) {
converters.remove(converter);
}
}
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
List<MediaType> supportedMediaTypes = new ArrayList<>();
//解析全部类型
supportedMediaTypes.add(MediaType.ALL); converter.setSupportedMediaTypes(supportedMediaTypes);
FastJsonConfig fastJsonConfig = new FastJsonConfig();
fastJsonConfig.setSerializerFeatures(SerializerFeature.WriteDateUseDateFormat,
SerializerFeature.WriteNullStringAsEmpty,
SerializerFeature.WriteMapNullValue,
SerializerFeature.DisableCircularReferenceDetect);
//日期格式化
fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
converter.setFastJsonConfig(fastJsonConfig);
converters.add(converter);
}
3.调用接口,返回结果成功,得知需要的类型为:application/vnd.spring-boot.actuator.v2+json

4.添加对类型application/vnd.spring-boot.actuator.v2+json的解析
//提供对admin的类型支持mediaType
MediaType mediaType = MediaType.valueOf("application/vnd.spring-boot.actuator.v2+json");
supportedMediaTypes.add(mediaType);
spring boot 与spring boot admin整合问题处理的更多相关文章
- Spring Boot + MyBatis + Druid + Redis + Thymeleaf 整合小结
Spring Boot + MyBatis + Druid + Redis + Thymeleaf 整合小结 这两天闲着没事想利用**Spring Boot**加上阿里的开源数据连接池**Druid* ...
- Spring Boot与Spring Security整合后post数据不了,403拒绝访问
http://blog.csdn.net/sinat_28454173/article/details/52251004 *************************************** ...
- [权限管理系统(四)]-spring boot +spring security短信认证+redis整合
[权限管理系统]spring boot +spring security短信认证+redis整合 现在主流的登录方式主要有 3 种:账号密码登录.短信验证码登录和第三方授权登录,前面一节Sprin ...
- Spring Boot,Spring Cloud,Eureka,Actuator,Spring Boot Admin,Stream,Hystrix
Spring Boot,Spring Cloud,Eureka,Actuator,Spring Boot Admin,Stream,Hystrix 一.Spring Cloud 之 Eureka. 1 ...
- Spring Kafka和Spring Boot整合实现消息发送与消费简单案例
本文主要分享下Spring Boot和Spring Kafka如何配置整合,实现发送和接收来自Spring Kafka的消息. 先前我已经分享了Kafka的基本介绍与集群环境搭建方法.关于Kafka的 ...
- Spring Boot(Spring的自动整合框架)
Spring Boot 是一套基于Spring框架的微服务框架,由于Spring是一个轻量级的企业开发框架,主要功能就是用于整合和管理其他框架,想法是将平时主流使用到的框架的整合配置预先写好,然后通过 ...
- 解决Spring Boot(2.1.3.RELEASE)整合spring-data-elasticsearch3.1.5.RELEASE报NoNodeAvailableException[None of the configured nodes are available
Spring Boot(2.1.3.RELEASE)整合spring-data-elasticsearch3.1.5.RELEASE报NoNodeAvailableException[None of ...
- Spring boot 整合spring Data JPA+Spring Security+Thymeleaf框架(上)
近期上班太忙所以耽搁了给大家分享实战springboot 框架的使用. 以下是spring boot 整合多个框架的使用. 首先是准备工作要做好. 第一 导入框架所需的包,我们用的事maven 进行 ...
- Spring 5.x 、Spring Boot 2.x 、Spring Cloud 与常用技术栈整合
项目 GitHub 地址:https://github.com/heibaiying/spring-samples-for-all 版本说明: Spring: 5.1.3.RELEASE Spring ...
- Spring Boot 2.0 快速集成整合消息中间件 Kafka
欢迎关注个人微信公众号: 小哈学Java, 每日推送 Java 领域干货文章,关注即免费无套路附送 100G 海量学习.面试资源哟!! 个人网站: https://www.exception.site ...
随机推荐
- 【Java】爬资源案例
也不知道为什么喜欢叫爬虫 搞明白原理之后原来就是解析网页代码获取关键字符串 现在的网页有很多解析出来就是JS了,根本不暴露资源地址 依赖一个JSOUP,其他靠百度CV实现 <!-- https: ...
- 【Layui】09 动画 Anim
文档地址: https://www.layui.com/demo/anim.html 8种动画 <fieldset class="layui-elem-field layui-fiel ...
- 强化学习入门书籍《DeepReinforcementLearningHands-On-SecondEdition》
前段时间在网上买了本强化学习入门的书籍,即<Deep-Reinforcement-Learning-Hands-On>,虽然是影印版的,但是感觉还是可以看看的,说的也蛮易懂的,感觉比现在市 ...
- 如何使用Python环境下的2D经典游戏仿真器(openai推出的)retro库运行游戏"刺猬索尼克" (SonicTheHedgehog-Genesis)
很多资料上都有使用游戏仿真器(openai推出的)retro库运行游戏"刺猬索尼克" (SonicTheHedgehog-Genesis),但是均没有给出详细的安装该款游戏的步骤 ...
- batch_norm在强化学习中建议使用的形式
def batch_norm(layer, **kwargs): """ Apply batch normalization to an existing layer. ...
- php日常收获
php 1.sprintf 用法(晚上写成blog w3cschool可查) 2.使用thinkphp getfield 方法时只查询一个字段默认返回第一条数据, 如果想要返回数组需要写成: $thi ...
- 如何在AWS上构建Apache DolphinScheduler
引言 随着云计算技术的发展,Amazon Web Services (AWS) 作为一个开放的平台,一直在帮助开发者更好的在云上构建和使用开源软件,同时也与开源社区紧密合作,推动开源项目的发展. 本文 ...
- Unreal使用GooglePAD生成AAB包,并加在fast-follow资源
1.修改obbfilter,设置需要添加到obb的pak文件 2.修改项目设置,打AAB包 3.cook stage生成所有Paks文件 4.将部分pak文件拷贝到Intermediate/Andro ...
- 关于Vue + element plus包装Component理解
关于Vue + element plus包装Component理解 一.关于编写思路 我以设计el-select选择框进行举例说明 父组件与Component传递params与Function使用Pr ...
- logback日志级别动态切换的四种方案
荐
生产环境中经常有需要动态修改日志级别. 现在就介绍几种方案 方案一:开启logback的自动扫描更新 配置如下 <?xml version="1.0" encoding=&q ...