【问题标题】:mvn endpoints-framework:openApiDocs does not read parametersmvn endpoints-framework:openApiDocs 不读取参数
【发布时间】:2017-11-24 07:13:53
【问题描述】:

我一直在试验 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

我已经截断了类路径以使阅读和发布输出更容易。有没有其他人遇到过这个问题?一些指针将不胜感激。

【问题讨论】:

  • 如果重要的话,项目和 POM 是由 eclipse 生成的。然而,我没有看到示例项目和我的 POM 中的差异。

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


【解决方案1】:

问题是因为 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 文件夹,该命令就会失败,并且从那里经过一些巧妙的试验和错误来找出问题所在的配置 xml。

无论如何,这个 servlet 映射及其丢失的副作用是否记录在任何地方?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-24
    • 1970-01-01
    • 2022-01-02
    • 2014-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多