我按照小教程(如果可以调用它)here来为petstore示例API生成服务器存根 . 然后我按照生成的文件中的 readme 指令进行操作,其中说:

To run the server, please execute the following:

mvn clean package jetty:run


You can then view the swagger listing here:

http://localhost:8080/v2/swagger.json


我第一次这样做,我得到了一个构建和编译错误 . 显然 `pom.xml` 文件缺少Jetty插件:

```xml
<plugin>
          <groupId>org.eclipse.jetty</groupId>
          <artifactId>jetty-maven-plugin</artifactId>
          <version>9.2.9.v20150224</version>
        </plugin>

以及 swagger-core 依赖:

<dependency>
        <groupId>io.swagger</groupId>
        <artifactId>swagger-core</artifactId>
        <version>1.5.9</version>
    </dependency>

虽然它们在 properties 属性下被提及如下:

<properties>
    <swagger-core-version>1.5.9</swagger-core-version>
    <jetty-version>9.2.9.v20150224</jetty-version>
    <resteasy-version>3.0.11.Final</resteasy-version>
    <slf4j-version>1.6.3</slf4j-version>
    <junit-version>4.8.1</junit-version>
    <servlet-api-version>2.5</servlet-api-version>
</properties>

虽然我可以在那之后成功做到 mvn clean package jetty:run

2016-07-28 14:40:11.740:INFO::main: Logging initialized @3196ms
[INFO] Configuring Jetty for project: swagger-jaxrs-resteasy-server
[INFO] webAppSourceDirectory not set. Trying src/main/webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes = /home/.../restserver/restapi/petstore/jaxrs-resteasy/target/classes
[INFO] Context path = /
[INFO] Tmp directory = /home/.../restserver/restapi/petstore/jaxrs-    resteasy/target/tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides =  none
[INFO] web.xml file = file:/home/.../restserver/restapi/petstore/jaxrs-    resteasy/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = /home/.../restserver/restapi/petstore/jaxrs-    resteasy/src/main/webapp
2016-07-28 14:40:11.799:INFO:oejs.Server:main: jetty-9.2.9.v20150224
2016-07-28 14:40:12.430:INFO:oejsh.ContextHandler:main: Started o.e.j.m.p.JettyWebAppContext@58ba5b30{/,file:/home/.../restserver/restapi/petstore/jaxrs-resteasy/src/main/webapp/,AVAILABLE}{file:/home/.../restserver/restapi/petstore/jaxrs-resteasy/src/main/webapp/}
2016-07-28 14:40:12.431:WARN:oejsh.RequestLogHandler:main: !RequestLog
2016-07-28 14:40:12.450:INFO:oejs.ServerConnector:main: Started     ServerConnector@6cd64b3f{HTTP/1.1}{0.0.0.0:8080}
2016-07-28 14:40:12.450:INFO:oejs.Server:main: Started @3906ms
[INFO] Started Jetty Server

我在尝试打开网站时仍然收到404:

$ wget http://localhost:8080/v2/swagger.json

--2016-07-28 14:58:42--  http://localhost:8080/v2/swagger.json
Resolving the hostname »localhost (localhost)«... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:8080... connected.
http request sent awaiting response... 404 not found
2016-07-28 14:58:42 ERROR 404: Not Found.

出了什么问题?

编辑:这是我的 mvn clean package -X jetty:run 输出:http://pasted.co/3ceba86c