这是我通过修改quarkus-quickstarts-main得到的代码:
package org.acme.spring.web;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@RestController
public class GreetingController {
@PostMapping("/post")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response allParams(String smell,
@RequestHeader HttpHeaders headers) {
return Response.ok("OK").build();
}
}
Exception during startup:
Caused by: java.lang.RuntimeException: Failed to process method 'org.acme.spring.web.GreetingController#allParams'
at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createResourceMethod(EndpointIndexer.java:703)
at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createEndpoints(EndpointIndexer.java:405)
at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createEndpoints(EndpointIndexer.java:286)
... 12 more
Caused by: java.lang.RuntimeException: Could not create converter for org.springframework.http.HttpHeaders for method javax.ws.rs.core.Response allParams(java.lang.String smell, org.springframework.http.HttpHeaders headers) on class org.acme.spring.web.GreetingController of type QUERY
at org.jboss.resteasy.reactive.server.processor.ServerEndpointIndexer.handleOtherParam(ServerEndpointIndexer.java:327)
at org.jboss.resteasy.reactive.server.processor.ServerEndpointIndexer.handleOtherParam(ServerEndpointIndexer.java:92)
at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.extractParameterInfo(EndpointIndexer.java:1335)
at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createResourceMethod(EndpointIndexer.java:536)
... 14 more
Caused by: java.lang.RuntimeException: Failed to find converter for org.springframework.http.HttpHeaders
at org.jboss.resteasy.reactive.server.processor.generation.converters.GeneratedConverterIndexerExtension.extractConverterImpl(GeneratedConverterIndexerExtension.java:106)
at org.jboss.resteasy.reactive.server.processor.ServerEndpointIndexer.extractConverter(ServerEndpointIndexer.java:513)
at org.jboss.resteasy.reactive.server.processor.ServerEndpointIndexer.handleOtherParam(ServerEndpointIndexer.java:323)
... 17 more
Can someone help how to make the HttpHeaders work?
I tried several alternatives but not working.
1条答案
按热度按时间ctehm74n1#
您正在混合JAX-RS和Spring Web类型,这是不可行的。
您应该改为执行以下操作: