mvn endpoints-framework:openApiDocs 不读取参数

mvn endpoints-framework:openApiDocs does not read parameters

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

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

问题是因为 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 映射及其缺失的副作用是否在任何地方都有记录?