为什么 maven swagger 插件不扫描外部模块?
Why maven swagger plugin isn't scanning external modules?
我们有一个 maven 多模块项目,它看起来大致像这样:
Parent
- admin
- microserviceA
- microserviceB
- microserviceC
微服务 A、B 和 C 公开功能特定的其余端点。
但是,admin 模块公开了通用的休息端点以实现弹性、健壮性和恢复。
为了记录我们的 API,我们使用带有 maven swagger 插件的 swagger 2.0。
我们为每个微服务使用的 pom.xml
如下所示:
微服务A:
<build>
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>${swagger.maven.plugin}</version>
<configuration>
<apiSources>
<apiSource>
<springmvc>false</springmvc>
<locations>
<location>com.xxx.a.resource</location>
<location>com.xxx.admin.resource</location>
</locations>
<schemes>http,https</schemes>
.....
</build>
微服务B:
<build>
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>${swagger.maven.plugin}</version>
<configuration>
<apiSources>
<apiSource>
<springmvc>false</springmvc>
<locations>
<location>com.xxx.b.resource</location>
<location>com.xxx.admin.resource</location>
</locations>
<schemes>http,https</schemes>
.....
</build>
微服务C:
<build>
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>${swagger.maven.plugin}</version>
<configuration>
<apiSources>
<apiSource>
<springmvc>false</springmvc>
<locations>
<location>com.xxx.c.resource</location>
<location>com.xxx.admin.resource</location>
</locations>
<schemes>http,https</schemes>
.....
</build>
问题: 即使在 maven swagger 插件 <location>
中明确指定管理包,maven 插件也不会在管理模块级别扫描其余端点。
PS: 我试过几个版本的maven插件。
有什么解决办法吗?
我认为这是 swagger 插件的一个限制,因为在他们的 Git 中打开了几个问题但没有答案。 (自 2017 年起)
我们有一个 maven 多模块项目,它看起来大致像这样:
Parent - admin - microserviceA - microserviceB - microserviceC
微服务 A、B 和 C 公开功能特定的其余端点。 但是,admin 模块公开了通用的休息端点以实现弹性、健壮性和恢复。
为了记录我们的 API,我们使用带有 maven swagger 插件的 swagger 2.0。
我们为每个微服务使用的 pom.xml
如下所示:
微服务A:
<build>
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>${swagger.maven.plugin}</version>
<configuration>
<apiSources>
<apiSource>
<springmvc>false</springmvc>
<locations>
<location>com.xxx.a.resource</location>
<location>com.xxx.admin.resource</location>
</locations>
<schemes>http,https</schemes>
.....
</build>
微服务B:
<build>
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>${swagger.maven.plugin}</version>
<configuration>
<apiSources>
<apiSource>
<springmvc>false</springmvc>
<locations>
<location>com.xxx.b.resource</location>
<location>com.xxx.admin.resource</location>
</locations>
<schemes>http,https</schemes>
.....
</build>
微服务C:
<build>
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>${swagger.maven.plugin}</version>
<configuration>
<apiSources>
<apiSource>
<springmvc>false</springmvc>
<locations>
<location>com.xxx.c.resource</location>
<location>com.xxx.admin.resource</location>
</locations>
<schemes>http,https</schemes>
.....
</build>
问题: 即使在 maven swagger 插件 <location>
中明确指定管理包,maven 插件也不会在管理模块级别扫描其余端点。
PS: 我试过几个版本的maven插件。
有什么解决办法吗?
我认为这是 swagger 插件的一个限制,因为在他们的 Git 中打开了几个问题但没有答案。 (自 2017 年起)