微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Swagger 3和Java> = 9拼图

如何解决Swagger 3和Java> = 9拼图

在基于Maven的Java11应用程序上配置Swagger 3时遇到了麻烦。

首先我在pom.xml中声明:

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>3.0.0</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>3.0.0</version>
    </dependency>

然后,我使用Spring Beans配置Swagger:

@Configuration
@EnableSwagger2
public class SwaggerConfig {

@Bean
public Docket swaggerSpringMvcPlugin() {
    return new Docket(DocumentationType.SWAGGER_2)
            .select()
            .apis(RequestHandlerSelectors.basePackage("com.***.***.controller.rest"))
            .paths(PathSelectors.any())
            .build()
            .apiInfo(MetaData());
}

private ApiInfo MetaData() {
    return new ApiInfoBuilder().title("***")
            .description("***")
            .contact(new Contact("**","www.***.com","**"))
            .license("Apache 2.0")
            .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
            .version("1.0.0")
            .build();
}

}

最后,我声明了module-info.java的要求:

    requires springfox.swagger2;
    requires springfox.spring.web;
    requires springfox.core;

当我尝试mvn clean install时,出现以下错误

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] error: the *** module reads package springfox.documentation.service from both springfox.core and springfox.spi
[ERROR] error: module springfox.spring.web reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module springfox.swagger2 reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module java.annotation reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module spring.core reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module java.validation reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module spring.beans reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module spring.web reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module spring.context reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module swagger.annotations reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module spring.boot reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module springfox.core reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module springfox.spi reads package springfox.documentation.service from both springfox.core and springfox.spi
[ERROR] error: module spring.boot.autoconfigure reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] /private/tmp/***/src/main/java/module-info.java:[1] error: module *** reads package springfox.documentation.service from both springfox.core and springfox.spi
[INFO] 15 errors 
[INFO] -------------------------------------------------------------

我猜错了,但我找不到。有人可以帮我吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。