无法为RESTEasy Swagger Codegen示例

时间:2016-07-28 13:00:34

标签: java maven swagger resteasy

我按照小教程(如果可以调用它)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插件:

        <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

0 个答案:

没有答案