在名称为“”的DispatcherServlet中找不到带有URI [/ ucp / ex]的HTTP请求的映射

时间:2018-11-12 10:29:04

标签: spring-mvc spring-boot spring-boot-test

目前,我确实从1.5.0迁移到2.0.4。在春季2中,我使用@RestControllerEndpoint而不是AbstractMVCEndpoint。

1.5.0代码:-运行正常

public class EventProcessingHealthEndpoint extends AbstractMvcEndpoint {..

2.0.4代码:

 @RestControllerEndpoint(id ="/v1")
    public class EventProcessingHealthEndpoint {
        @GetMapping
        public String example1() {
            return "Example read";
        }

当我试图获得回应时-工作正常。

http://localhost:7021/ucp/v1-返回示例读取

但在单元测试中。

  No mapping found for HTTP request with URI [/ucp/ex] in DispatcherServlet with name '

单元测试代码:

class NexmoControllerSpec extends Specification {
        EventProcessingClientV2 eventProcessing = EasyMock.createStrictMock(EventProcessingClientV2)
    NexmoEventTranslator eventTranslator = new NexmoEventTranslator(eventProcessing : eventProcessing, encryptionService : encryptionService)
    EventProcessingHealthEndpoint controller = new EventProcessingHealthEndpoint(eventTranslator : eventTranslator)
    MockMvc mockMvc = standaloneSetup(controller).build()

         def "Incoming"() {
        expect:
           mockMvc.perform(get("http://localhost:7021/ucp/ex")).andExpect(status().isOk())

当我将@RestControllerEndpoint更改为@RestController时-单元测试正常。

请帮助我找到解决方法。

0 个答案:

没有答案