question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Upgrading to springfox-boot-starter version 3 causes compilation errors in generated OpenAPIDocumentationConfig class

See original GitHub issue

I must be missing something obvious when migrating to springfox-boot-starter version 3.

I have a small simple spring boot demo project, for generating server code based on an OpenAPI version 3 (OAS3) file. It is working with springfox-swagger2 version 2.9.2, but it generates OAS2 json file in api-docs (I would like OAS3). It’s using the following dependencies:

<dependencies>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-web</artifactId>
		<exclusions>
			<exclusion>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-starter-tomcat</artifactId>
			</exclusion>
		</exclusions>
	</dependency>

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-tomcat</artifactId>
		<scope>provided</scope>
	</dependency>

	<!-- Required for swagger code generation -->
	<dependency>
		<groupId>io.springfox</groupId>
		<artifactId>springfox-swagger2</artifactId>
		<version>2.9.2</version>
	</dependency>

	<!-- Required for openapi-generator-maven-plugin >= 4.2.3 (3.3.4 does not need it) -->
	<dependency>
		<groupId>org.openapitools</groupId>
		<artifactId>jackson-databind-nullable</artifactId>
		<version>0.2.1</version>
	</dependency>

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-test</artifactId>
		<scope>test</scope>
		<exclusions>
			<exclusion>
				<groupId>org.junit.vintage</groupId>
				<artifactId>junit-vintage-engine</artifactId>
			</exclusion>
		</exclusions>
	</dependency>
</dependencies>

I am trying to upgrade to springfox-boot-starter version 3.0.0. Following the migration instructions, I removed the swagger2 dependency:

<dependencies>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-web</artifactId>
		<exclusions>
			<exclusion>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-starter-tomcat</artifactId>
			</exclusion>
		</exclusions>
	</dependency>

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-tomcat</artifactId>
		<scope>provided</scope>
	</dependency>

	<!-- Required for swagger code generation -->
	<!-- For new projects [ref: https://github.com/springfox/springfox] -->
	<dependency>
		<groupId>io.springfox</groupId>
		<artifactId>springfox-boot-starter</artifactId>
		<version>3.0.0</version>
	</dependency>

	<!-- Required for openapi-generator-maven-plugin >= 4.2.3 (3.3.4 does not need it) -->
	<dependency>
		<groupId>org.openapitools</groupId>
		<artifactId>jackson-databind-nullable</artifactId>
		<version>0.2.1</version>
	</dependency>

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-test</artifactId>
		<scope>test</scope>
		<exclusions>
			<exclusion>
				<groupId>org.junit.vintage</groupId>
				<artifactId>junit-vintage-engine</artifactId>
			</exclusion>
		</exclusions>
	</dependency>
</dependencies>

However, I am getting some issues:

  • Generated class OpenAPIDocumentationConfig has a @EnableSwagger2 annotation. As migration instructions tells to remove those, I didn’t expect the generator to include it in the code. Generated classes shouldn’t be edited manually.
  • And the following compilation errors:
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR
[INFO] -------------------------------------------------------------
[ERROR] .../generated-sources/openapi/src/main/java/poc/config/OpenAPIDocumentationConfig.java:[14,48] cannot find symbol
  symbol:   class RelativePathProvider
  location: package springfox.documentation.spring.web.paths
[ERROR] .../generated-sources/openapi/src/main/java/poc/config/OpenAPIDocumentationConfig.java:[50,53] cannot find symbol
  symbol:   class RelativePathProvider
  location: class es.fnmt.ceres.rest.autec.poc.config.OpenAPIDocumentationConfig
[ERROR] .../generated-sources/openapi/src/main/java/poc/config/OpenAPIDocumentationConfig.java:[44,31] incompatible types: es.fnmt.ceres.rest.autec.poc.config.OpenAPIDocumentationConfig.BasePathAwareRelativePathProvider cannot be converted to springfox.documentation.PathProvider
[ERROR] .../generated-sources/openapi/src/main/java/poc/config/OpenAPIDocumentationConfig.java:[58,9] method does not override or implement a method from a supertype
[ERROR] .../generated-sources/openapi/src/main/java/poc/config/OpenAPIDocumentationConfig.java:[60,91] cannot find symbol
  symbol: method applicationPath()
[ERROR] .../generated-sources/openapi/src/main/java/poc/config/OpenAPIDocumentationConfig.java:[63,9] method does not override or implement a method from a supertype

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:11
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ChillyWecommented, May 26, 2021

Same issue here

1reaction
billbarnicommented, May 26, 2021

Same issue here…

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Spring Boot 2.6.0 / Spring fox 3 - Failed to start bean ...
This problem's caused by a bug in Springfox. It's making an assumption about how Spring MVC is set up that doesn't always hold...
Read more >
Springfox Reference Documentation - GitHub Pages
Springfox works by examining an application, once, at runtime to infer API semantics based on spring configurations, class structure and various ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found