gpt4 book ai didi

java - 阐明:在我的 wadl 中,为什么我的所有资源路径属性都以 "/rest"为前缀?

转载 作者:行者123 更新时间:2023-12-02 06:14:05 25 4
gpt4 key购买 nike

资源类定义如下:

@Path("v1")
@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public class RestApi {

我有一个这样定义的方法:

@GET
@Path("patients")
public String patients(

当我运行maven命令时运行enunciate doc 目标,生成的 wadl 如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<wadl:application xmlns:wadl="http://wadl.dev.java.net/2009/02" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<wadl:doc xmlns:enunciate="http://enunciate.codehaus.org/" enunciate:generatedBy="Enunciate-1.27"/>
<wadl:grammars>
<wadl:include href="ns0.xsd"/>
</wadl:grammars>
<wadl:resources base="http://localhost:8888/app/api">
...
<wadl:resource path="/rest/v1/patients">
<wadl:method name="GET">

这个“/rest/”来自资源路径中的哪里?我已经在我的项目中到处搜索了,但没有提到它。

这是我的 enunciate.xml 配置文件:

<enunciate label="Rest API"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<deployment host="localhost:8888" context="/app/api"/>

</enunciate>

最佳答案

显然“/rest”只是一个默认值。您可以通过将其添加到 enunciate.xml 文件来将其更改为空:

<services>
<rest defaultRestSubcontext="/" />
</services>

关于java - 阐明:在我的 wadl 中,为什么我的所有资源路径属性都以 "/rest"为前缀?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21640356/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com