解决问题:AbstractWebMvcEndpointHandlerMapping$BadOperationRequestException: Missing parameters: XXX

解决问题:org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$BadOperationRequestException: Missing parameters: XXX
springboot2.0.2自定义Endpoint
自定义代码如下:


import java.util.*;

import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.annotation.Selector;
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
import org.springframework.boot.actuate.endpoint.web.EndpointMapping;
import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes;
import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint;
import org.springframework.boot.actuate.endpoint.web.annotation.WebEndpoint;
import org.springframework.boot.actuate.web.mappings.MappingDescriptionProvider;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.web.cors.CorsConfiguration;

/**
 * 
 * @author Simon
 * @version 2018年5月25日
 *
 * 自定义监视端点
 */
@Endpoint(id = "person")
@Component
public class PersonEndpoint {
    private final Map<String, Person> people = new HashMap<>();

    PersonEndpoint() {
        this.people.put("Simon", new Person("Michael Simon"));
        this.people.put("Alan", new Person("Rowena Alan"));
        this.people.put("Bryant", new Person("Barry Bryant"));
    }

    @ReadOperation
    public Map<String, Person> getAll() {
        return people;
    }

    @ReadOperation
    public Person getPerson(@Selector String person) {
        return this.people.get(person);
    }

    @WriteOperation
    public void updatePerson(@Selector String name, String person) {
        this.people.put(name, new Person(person));
    }

}


按照springboot官方文档暗示调用路径传递name参数
例如http://localhost:8888/actuator/person/{name}
接口调用会跳出异常
org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$BadOperationRequestException: Missing parameters: XXX

方式解决
调用接口http://localhost:8888/actuator/person/ignored?person=Simon

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值