Issue
I have a new Spring Boot 2.5.3 project and got some weird issue. I am trying to add this dependency in my pom.xml, but Maven 3.6.3 can't resolve the dependency for some reason.
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi</artifactId>
<version>1.5.10</version>
</dependency>
When running mvn clean install -U
both from IDE (IntelliJ) and command prompt (bash / cmd), the printed exception is
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.myapp:api >-----------------------
[INFO] Building MyApp API 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.237 s
[INFO] Finished at: 2021-09-10T15:07:26+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project api: Could not resolve dependencies for project com.myapp:api:jar:0.0.1-SNAPSHOT: Failure to find org.springdoc:springdoc-openapi:jar:1.5.10 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
The dependency exists in Maven Central which makes things weird.
Tried on 2 different machines with Windows and CentOS operating systems and the result is the same.
Solution
This dependency does not have a jar type. It's POM type only.
You need to use the same dependency declaration as the Maven Central suggests:
<!-- https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi</artifactId>
<version>1.5.10</version>
<type>pom</type>
</dependency>
Answered By - Dawid Pura