【问题标题】:Swagger dependency not recognized by mavenMaven 无法识别 Swagger 依赖项
【发布时间】:2018-09-27 20:35:46
【问题描述】:

我正在尝试将 springfox/swagger 添加到我的 Spring Boot 应用程序中,但是当添加到 pom 文件时,maven 无法识别依赖项的版本。不幸的是,我找不到它背后的原因。这是我的 pom 文件的片段:

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

版本被标记为红色,因为 Maven 无法识别。这种行为背后的原因可能是什么? 我正在使用 maven 3.3.9。

【问题讨论】:

  • 我使用 maven Central 检查了您的依赖项。它们似乎存在。你在使用 IDE 吗?如果是的话是哪个?红色标记是否带有任何错误消息?
  • 我正在使用 IntelliJ,错误消息显示“未找到依赖项 xyz”
  • 您是否配置了私有 maven 存储库? (在您的 POM.xml 或其他地方?)

标签: java maven swagger swagger-ui springfox


【解决方案1】:

这些工件存在于 Maven 存储库中,因此您应该能够将它们添加为依赖项。这种行为有三个可能的原因:

  1. 您已在 pom.xml 中定义了自定义存储库。
  2. 您的 IDE 中有一个自定义的 maven 配置。
  3. 您已在 settings.xml maven 配置文件中定义了一个自定义的存储库列表(如果您使用类似 Nexus 来提供库,则会发生这种情况)。

我也查了Springfox Reference,你可以直接添加这个自定义仓库:

<repositories>
    <repository>
      <id>jcenter-snapshots</id>
      <name>jcenter</name>
      <url>https://jcenter.bintray.com/</url>
    </repository>
</repositories>

【讨论】:

  • 添加自定义存储库解决了我的问题,我不知道根本原因是什么,但仍然存在。为您的回答 +1
猜你喜欢
  • 2021-04-16
  • 1970-01-01
  • 1970-01-01
  • 2017-02-22
  • 2021-03-27
  • 1970-01-01
  • 2023-01-18
  • 2016-11-05
  • 2013-08-21
相关资源
最近更新 更多