mvn端点 - 框架:openApiDocs不读取参数

时间:2017-11-24 07:13:54

标签: java maven google-app-engine google-cloud-endpoints

我一直在尝试使用GAE Endpoint框架,并且教程中的步骤说要执行此maven命令:

mvn endpoints-framework:openApiDocs

根据我的理解,此命令将生成OpenAPI文档,并在最后提示文件的位置。但是,它似乎无法读取maven传递给它的参数,而是打印用法语句,如下所示:

[INFO] --- endpoints-framework-maven-plugin:1.0.2:openApiDocs (default-cli) @ demoapp ---
[INFO] Endpoints Tool params : [get-openapi-doc, -o, C:\projects\demoapp-backend\target\openapi-docs\openapi.json, -cp,C:\..., -w, C:\projects\demoapp-backend\src\main\webapp, -h, demo-app.appspot.com]
get-openapi-doc

Generates an OpenAPI document

Usage: <Endpoints tool> get-openapi-doc <options> <service class>...

Options:
  -cp CLASSPATH, --classpath=CLASSPATH
    Lets you specify the service class or classes from a path other than the
    default <war-directory>/WEB-INF/libs and <war-directory>/WEB-INF/classes,
    where <war-directory is the directory specified in the war option, or simply
    ./war if that option is not supplied.
  -o OUTPUT_FILE, --output=OUTPUT_FILE
    Sets the file where output will be written to. Default: ./openapi.json
  -w WAR_PATH, --war=WAR_PATH
    Sets the path to the war directory where web-appengine.xml and other
    metadata are located. Default: ./war.
  -h HOSTNAME, --hostname=HOSTNAME
    Sets the hostname for the generated document. Default is the app's default
    hostname.
  -p BASE_PATH, --path=BASE_PATH
    Sets the base path for the generated document. Default is /_ah/api.

Example:
  <Endpoints tool> get-openapi-doc com.google.devrel.samples.ttt.spi.BoardV1 com.google.devrel.samples.ttt.spi.ScoresV1

我已经截断了类路径,以便更轻松地阅读和发布输出。还有其他人遇到过这个问题吗?一些指示将非常感激。

1 个答案:

答案 0 :(得分:2)

问题是因为web.xml缺少端点servlet映射。

<servlet>
        <servlet-name>EndpointsServlet</servlet-name>
        <servlet-class>com.google.api.server.spi.EndpointsServlet</servlet-class>
        <init-param>
            <param-name>services</param-name>
            <param-value>com.example.demoapp.Echo</param-value>
        </init-param>
</servlet>

我通过确保pom与 mvn endpoints-framework:openApiDocs 命令正在运行的项目相同来跟踪它,并从那里将源文件夹复制到工作项目中。复制src文件夹后命令失败,并从那里进行了一些巧妙的试验和错误,以找出问题所在的配置xmls。

无论如何,这个servlet映射及其遗漏的副作用是否记录在哪里?

相关问题