防止Jersey为HTTP选项返回XML

防止Jersey为HTTP选项返回XML,jersey,jax-rs,weblogic12c,Jersey,Jax Rs,Weblogic12c,我使用Jersey定义了一个JAX-RS服务,如下所示,它部署在WebLogic12.2.1上。它很好用 @Path("/Profile") public class ProfileServices { @POST @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @Path("{ServiceName}") public Response service(@PathParam("Servic

我使用Jersey定义了一个JAX-RS服务,如下所示,它部署在WebLogic12.2.1上。它很好用

@Path("/Profile")
public class ProfileServices {

    @POST
    @Consumes(APPLICATION_JSON)
    @Produces(APPLICATION_JSON)
    @Path("{ServiceName}")
    public Response service(@PathParam("ServiceName") String serviceName, String message) {
        ...
    }
}
但是,当使用HTTP选项调用服务时,Jersey返回了一个WADL以及响应头Allow:POST,OPTIONS

<ns0:application xmlns:ns0="http://wadl.dev.java.net/2009/02">
   <ns0:doc ns1:generatedBy="Jersey: 2.22.4 2016-11-30 13:33:53" xmlns:ns1="http://jersey.java.net/"/>
   <ns0:grammars/>
   <ns0:resources base="https://xxx.xxx.xxx.xxx:nnnn/">
      <ns0:resource path="XXXXX">
         <ns0:method id="service" name="POST">
            <ns0:request>
               <ns0:representation mediaType="application/json"/>
            </ns0:request>
            <ns0:response>
               <ns0:representation mediaType="application/json"/>
            </ns0:response>
         </ns0:method>
      </ns0:resource>
   </ns0:resources>
</ns0:application>

我如何防止泽西退回这一捆?我不想向用户透露球衣的版本。我对响应状态和标题没有意见,但我不想返回内容。如果不可能,是否可以不返回球衣信息

我使用的是javax.ws.rs.core.Application,不需要web.xml来指定servlet

编辑

事实上,我在应用程序中重写了以下方法:

@Override
public Map<String, Object> getProperties() {
    Map<String, Object> props = new HashMap<>();
    props.put("jersey.config.server.wadl.disableWadl", true);
    return props;
}
@覆盖
公共映射getProperties(){
Map props=newhashmap();
put(“jersey.config.server.wadl.disableWadl”,true);
返回道具;
}
但当我重新部署时,我得到了以下例外:

org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl(requiredType=WadlApplicationContext,parent=JaxRsMonitoringListener,qualifiers={},position=-1,optional=false,self=false,unqualified=null,1838803099)
    at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:75)
    at org.jvnet.hk2.internal.Utilities.justInject(Utilities.java:1012)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.inject(ServiceLocatorImpl.java:1008)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.inject(ServiceLocatorImpl.java:986)
    at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:617)
    at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:184)
    at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350)
    at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255)
    at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:347)
    at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:392)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369)
    at javax.servlet.GenericServlet.init(GenericServlet.java:244)
    ...
org.glassfish.hk2.api.UnsatifiedPendencyException:SystemInjecteeImpl上没有可供注入的对象(requiredType=WadlaplicationContext,parent=JAXRMonitoringListener,限定符={},position=-1,optional=false,self=false,unqualified=null,1838803099)
在org.jvnet.hk2.internal.ThreeThirtyResolver.resolve上(ThreeThirtyResolver.java:75)
位于org.jvnet.hk2.internal.Utilities.justInject(Utilities.java:1012)
位于org.jvnet.hk2.internal.ServiceLocatorImpl.inject(ServiceLocatorImpl.java:1008)
位于org.jvnet.hk2.internal.ServiceLocatorImpl.inject(ServiceLocatorImpl.java:986)
位于org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:617)
位于org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:184)
位于org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350)
位于org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347)
位于org.glassfish.jersey.internal.Errors.process(Errors.java:315)
位于org.glassfish.jersey.internal.Errors.process(Errors.java:297)
位于org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255)
位于org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:347)
位于org.glassfish.jersey.servlet.WebComponent(WebComponent.java:392)
位于org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
位于org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369)
位于javax.servlet.GenericServlet.init(GenericServlet.java:244)
...

将属性
ServerProperties.WADL\u功能\u DISABLE
设置为true。在应用程序类中,重写
publicmap getProperties()
,并将属性放入映射中。如果您没有使用任何特定于Jersey的代码,请使用字符串
Jersey.config.server.wadl.disableWadl
作为密钥,而不是constantHi Paul,我以前已经按照您的建议执行了(请参见上面的编辑),但我遇到了异常。何时发生此错误?当应用程序启动时。