简体   繁体   English

跨多个项目的REST API的Maven WADL插件

[英]Maven WADL plugin for REST API spanning multiple project

I'm trying the maven-wadl-plugin . 我正在尝试maven-wadl-plugin (I didn't find any documentation besides the Javadoc .) (除了Javadoc之外我没有找到任何文档。)

My project has the classes used for REST endpoints amongst different Maven modules. 我的项目具有用于不同Maven模块之间的REST端点的类。 And the WADL plugin seems not to be able to reach for them. WADL插件似乎无法达到目标。 So running on a single module fails with: 因此,在单个模块上运行失败并显示:

[ERROR] Failed to execute goal 
   com.sun.jersey.contribs:maven-wadl-plugin:1.19.4:generate (generate) 
on project bpds-resources: Execution generate of goal com.sun.jersey.contribs:maven-wadl-plugin:1.19.4:generate 
failed: A required class was missing while executing 
  com.sun.jersey.contribs:maven-wadl-plugin:1.19.4:generate: com/.../common/dto/BoxRequestDto

The plugin doesn't support running from the root project either. 该插件也不支持从根项目运行。

1) AFAIK, maven-wadl-plugin parses the sources. 1)AFAIK, maven-wadl-plugin解析源。 My project results in a one big shaded .jar so the plugin could consume that and not care about the internal dependencies. 我的项目生成一个大阴影的.jar因此插件可以使用它,而不必关心内部依赖项。 Can I make the plugin scan the artifact instead? 我可以改为让插件扫描工件吗?

2) Is there a way to make it work over multiple projects? 2)有没有办法使它在多个项目中都能工作?

I figured out that adding the project dependency to the scanned module works. 我发现将项目依赖项添加到扫描模块中是可行的。 So I have added the attribute with the DTO classes and now it works: 因此,我在DTO类中添加了属性,现在它可以工作了:

<build>
    <plugins>
        <plugin>
            <groupId>com.sun.jersey.contribs</groupId>
            <artifactId>maven-wadl-plugin</artifactId>
            <version>1.19.4</version>
            <dependencies>
                <dependency>
                    <groupId>org.glassfish.jersey.core</groupId>
                    <artifactId>jersey-server</artifactId>
                    <version>2.25.1</version>
                </dependency>
                <dependency>
                    <groupId>com.fasterxml.jackson.jaxrs</groupId>
                    <artifactId>jackson-jaxrs-json-provider</artifactId>
                    <version>2.8.10</version>
                </dependency>
                <dependency>
                    <groupId>org.glassfish.jersey.media</groupId>
                    <artifactId>jersey-media-multipart</artifactId>
                    <version>2.25.1</version>
                </dependency>
                <dependency>
                    <groupId>com.mycompany.bpds</groupId>
                    <artifactId>bpds-common</artifactId>
                    <version>${project.version}</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <id>generate</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <phase>package</phase>

                    <configuration>
                        <wadlFile>${project.build.directory}/endpoints.wadl</wadlFile>
                        <formatWadlFile>true</formatWadlFile>
                        <baseUri>http://localhost:9021/</baseUri>
                        <packagesResourceConfig>
                            <param>com.mycompany.rest</param>
                        </packagesResourceConfig>
                        <wadlGenerators>
                            <!-- Doesn't work wit current version of Xerces.
                            <wadlGeneratorDescription>
                                <className>com.sun.jersey.server.wadl.generators.WadlGeneratorApplicationDoc</className>
                                <properties>
                                    <property>
                                        <name>applicationDocsFile</name>
                                        <value>${project.build.directory}/app-wadl-doc.xml</value>
                                    </property>
                                </properties>
                            </wadlGeneratorDescription>
                            <wadlGeneratorDescription>
                                <className>com.sun.jersey.server.wadl.generators.WadlGeneratorGrammarsSupport</className>
                                <properties>
                                    <property>
                                        <name>grammarsFile</name>
                                        <value>${project.build.directory}/app-wadl-grammar.xml</value>
                                    </property>
                                </properties>
                            </wadlGeneratorDescription>
                            -->
                        </wadlGenerators>
                    </configuration>
                </execution>
            </executions>
        </plugin>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM