我具有以下JAX-RS方法签名:
void searchSignatureService(@QueryParam("from") ZonedDateTime from, @QueryParam("to") ZonedDateTime to, @HeaderParam("If-None-Match") String if_None_Match, @HeaderParam("Authorization") String authorization,
@HeaderParam("Accept") String accept, @Suspended AsyncResponse async);
当我尝试使用网络浏览器点击它时,出现如下异常:
[[FATAL] No injection source found for a parameter of type public void com.example.jaxrs.service.signature.SignatureResource.searchSignatureService(java.time.ZonedDateTime,java.time.ZonedDateTime,java.lang.String,java.lang.String,java.lang.String,javax.ws.rs.container.AsyncResponse) at index 0.; source='ResourceMethod{httpMethod=GET, consumedTypes=[], producedTypes=[application/xml, application/json], suspended=true, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class com.example.jaxrs.service.signature.SignatureResource, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@588562ac]}, definitionMethod=public abstract void com.example.jaxrs.api.SignatureResource.searchSignatureService(java.time.ZonedDateTime,java.time.ZonedDateTime,java.lang.String,java.lang.String,java.lang.String,javax.ws.rs.container.AsyncResponse), parameters=[Parameter [type=class java.time.ZonedDateTime, source=from, defaultValue=null], Parameter [type=class java.time.ZonedDateTime, source=to, defaultValue=null], Parameter [type=class java.lang.String, source=If-None-Match, defaultValue=null], Parameter [type=class java.lang.String, source=Authorization, defaultValue=null], Parameter [type=class java.lang.String, source=Accept, defaultValue=null], Parameter [type=interface javax.ws.rs.container.AsyncResponse, source=javax.ws.rs.container.Suspended, defaultValue=null]], responseType=void}, nameBindings=[]}']
鉴于当我尝试将java.util.Date转换为java.time.ZonedDateTime时启动了异常,我假设“注入源”与将日期字符串映射到java.time.ZonedDateTime有关。
是否需要缺少依赖项才能使java.time包与jersey配合使用?
我当前的依赖项如下:
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.27</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.27</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.bundles</groupId>
<artifactId>jaxrs-ri</artifactId>
<version>2.27</version>
</dependency>