英文:
Swagger Error with version upgrading version > 2.6.1 - NoSuchMethodException: BasePathAwareServicesProvider.<init>()
问题
我已经将您提供的内容翻译如下:
我已经将springfox升级到了2.7.0版本(以及2.9.2):
<springfox.version>2.7.0</springfox.version>
<spring-boot.version>1.3.3.RELEASE</spring-boot.version>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-data-rest</artifactId>
<version>${springfox.version}</version>
</dependency>
尝试启动应用程序时,我遇到了以下错误:
org.springframework.beans.factory.UnsatisfiedDependencyException:
在URL中定义的名为'documentationPluginsBootstrapper'的bean创建错误
[jar:file:.....jar!/lib/springfox-spring-web-2.7.0.jar!/springfox/documentation/spring/web/plugins/DocumentationPluginsBootstrapper.class]:
通过构造函数参数无法满足的依赖项,索引为1,类型为[java.util.List]:在URL中定义的名为'basePathAwareServicesProvider'的bean创建错误
[jar:file:/..............!/lib/springfox-data-rest-2.7.0.jar!/springfox/documentation/spring/data/rest/BasePathAwareServicesProvider.class]:
无法实例化bean;嵌套异常是
org.springframework.beans.BeanInstantiationException:无法实例化
[springfox.documentation.spring.data.rest.BasePathAwareServicesProvider]:
找不到默认构造函数;嵌套异常是
java.lang.NoSuchMethodException:
springfox.documentation.spring.data.rest.BasePathAwareServicesProvider.();
嵌套异常是
org.springframework.beans.factory.BeanCreationException:在URL中定义的名为'basePathAwareServicesProvider'的bean创建错误
[jar:file:............!/lib/springfox-data-rest-2.7.0.jar!/springfox/documentation/spring/data/rest/BasePathAwareServicesProvider.class]:
无法实例化bean;嵌套异常是
org.springframework.beans.BeanInstantiationException:无法实例化
[springfox.documentation.spring.data.rest.BasePathAwareServicesProvider]:
找不到默认构造函数;嵌套异常是
java.lang.NoSuchMethodException:
springfox.documentation.spring.data.rest.
BasePathAwareServicesProvider.init()
找不到默认构造函数;BasePathAwareServicesProvider.init()
为了避免与swaggers-ui.html出现一些错误,我已经对类进行了如下注解:
@Configuration
@Profile("swaggerEnabled")
@EnableSwagger2
@EnableWebMvc
@Import(SpringDataRestConfiguration.class)
public class SwaggerConfiguration {
Springboot应用程序:
@EnableSwagger2
@EnableWebMvc
@SpringBootApplication
@Import(value = {
......class,})
@Order(Ordered.HIGHEST_PRECEDENCE)
@ComponentScan(basePackages = {"....."})
public class PlatformApiApplication {
我尝试了一些来自GitHub的解决方案,但都没有奏效。有人可以帮助我吗?谢谢。
英文:
I have upgraded springfox to version 2.7.0(and 2.9.2):
<springfox.version>2.7.0</springfox.version>
<spring-boot.version>1.3.3.RELEASE</spring-boot.version>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-data-rest</artifactId>
<version>${springfox.version}</version>
</dependency>
and trying to start the application I get the next error:
> org.springframework.beans.factory.UnsatisfiedDependencyException:
> Error creating bean with name 'documentationPluginsBootstrapper'
> defined in URL
> [jar:file:.....jar!/lib/springfox-spring-web-2.7.0.jar!/springfox/documentation/spring/web/plugins/DocumentationPluginsBootstrapper.class]:
> Unsatisfied dependency expressed through constructor argument with
> index 1 of type [java.util.List]: Error creating bean with name
> 'basePathAwareServicesProvider' defined in URL
> [jar:file:/..............!/lib/springfox-data-rest-2.7.0.jar!/springfox/documentation/spring/data/rest/BasePathAwareServicesProvider.class]:
> Instantiation of bean failed; nested exception is
> org.springframework.beans.BeanInstantiationException: Failed to
> instantiate
> [springfox.documentation.spring.data.rest.BasePathAwareServicesProvider]:
> No default constructor found; nested exception is
> java.lang.NoSuchMethodException:
> springfox.documentation.spring.data.rest.BasePathAwareServicesProvider.<init>();
> nested exception is
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'basePathAwareServicesProvider' defined in URL
> [jar:file:............!/lib/springfox-data-rest-2.7.0.jar!/springfox/documentation/spring/data/rest/BasePathAwareServicesProvider.class]:
> Instantiation of bean failed; nested exception is
> org.springframework.beans.BeanInstantiationException: Failed to
> instantiate
> [springfox.documentation.spring.data.rest.BasePathAwareServicesProvider]:
> No default constructor found; nested exception is
> java.lang.NoSuchMethodException:
> springfox.documentation.spring.data.rest.
BasePathAwareServicesProvider. init ()
No default constructor found; BasePathAwareServicesProvider. init ()
I have annotated the classes like this in order to avoid some errors with swaggers-ui.html:
@Configuration
@Profile("swaggerEnabled")
@EnableSwagger2
@EnableWebMvc
@Import(SpringDataRestConfiguration.class)
public class SwaggerConfiguration {
The Springboot application:
@EnableSwagger2
@EnableWebMvc
@SpringBootApplication
@Import(value = {
......class,})
@Order(Ordered.HIGHEST_PRECEDENCE)
@ComponentScan(basePackages = {"....."})
public class PlatformApiApplication {
I've tried some solutions from github but nothing works. Can somebody help me? thanks.
答案1
得分: 0
移除这一行:
@Import(SpringDataRestConfiguration.class)
错误消失。
英文:
Removing the line:
@Import(SpringDataRestConfiguration.class)
The error dissapears
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论