I have a Spring Boot (2.2.6) project that has another starter as a dependency:
<dependency>
<groupId>com.companyX.teamY</groupId>
<artifactId>Z-starter</artifactId>
<version>0.0.1</version>
</dependency>
But I get a error java.lang.IllegalStateException: Failed to introspect Class
because of missing
java.lang.ClassNotFoundException: springfox.documentation.spring.web.plugins.Docket
I don't find any springfox under project's external libraries dropdown (in IntelliJ) so I digged into the source of custom starter and found this:
@Bean
@ConditionalOnMissingBean(Docket.class)
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(new ApiInfoBuilder()
.title("A Sample Project")
.version("0.0.1")
.build())
.select()
.apis(basePackage("com.companyX"))
.build();
}
But the starter project does have
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
in its pom.xml
. If I add above to my Spring Boot project the error goes away so I am not sure why IntelliJ or maven isn't able to resolve such dependency: Spring Boot APP -> Custom Starter -/> SpringFox
. What am I missing here?
Versions:
- Java SDK: 1.8.0_231
- Maven: 3.6.2
- SpringBoot: 2.2.6.RELEASE for both projects
I ran mvn clean install
and did not see any errors. The error only appears for one of those contextloads test method.
EDIT:
After some digging, this looks to be an issue with transitive dependencies not being resolved, but then I followed the steps of running mvn install
on both projects to no avail.