java 在Jersey 1.19.1上禁用WADL生成

f0ofjuux  于 2023-06-04  发布在  Java
关注(0)|答案(3)|浏览(428)

我在一个Web项目中使用Jersey 1.19.1,使用Java+Jboss。
每次我从Webservice请求一些东西时,它都会在server.log上显示以下条目:

ERROR [STDERR] com.sun.jersey.server.wadl.generators.AbstractWadlGeneratorGrammarGenerator attachTypes
INFO: Couldn't find grammar element for class java.lang.String

搜索如何禁用它,我发现了这个:

<init-param>
        <param-name>com.sun.jersey.config.server.wadl.DisableWADL</param-name>
        <param-value>true</param-value>
    </init-param>

但对我来说什么都没改变。
我如何禁用WADL,这样这个恼人的消息就不会再出现了?
下面是servlet的完整条目:

<servlet>
    <servlet-name>windi-mobile-service</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>com.sun.jersey.config.server.wadl.DisableWADL</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>br.com.altimus.mobile.service</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
siotufzp

siotufzp1#

想明白了在版本1.19.x上,参数名需要如下所示:

com.sun.jersey.config.feature.DisableWADL
eqqqjvef

eqqqjvef2#

使用ApplicationConfig禁用以下属性
jersey.config.server.wadl.disableWadl =“true”

@ApplicationPath("/rest")
    public class ApplicationConfig extends Application {

        @Override
        public Map<String, Object> getProperties() {

            Map<String, Object> properties = new HashMap<String, Object>();
            properties.put("jersey.config.server.provider.packages", "com.study.rest");
            properties.put("jersey.config.server.wadl.disableWadl", "true");
            properties.put("jersey.config.server.provider.classnames","org.glassfish.jersey.media.multipart.MultiPartFeature");
            properties.put(CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER,"0");
            System.out.println("getProperties:-> CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER_SERVER :" + CommonProperties.getValue(properties,CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER,String.class));
            return properties;
        }
}

你可以检查可能是而不是DisableWADLdisableWadl 将工作。

d6kp6zgx

d6kp6zgx3#

要禁用wadl生成,必须将disableWadl设置为true。而且还应该设置allowSystemPropertyProvider属性

jersey.config.allowSystemPropertiesProvider=true jersey.config.server.wadl.disableWadl=true

相关问题