我正在尝试使用swagger-codegen-maven-plugin
生成Api客户端类。
我收到以下异常:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.boot.autoconfigure.security.oauth2.OAuth2AutoConfiguration]; nested exception is java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/bind/Bindable
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:616)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:299)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245)
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:606)
at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:548)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:185)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:308)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:272)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:92)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at com.myApp.Application.main(Application.java:18)
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/bind/Bindable
at org.springframework.boot.autoconfigure.security.oauth2.resource.OAuth2ResourceServerConfiguration$ResourceServerCondition.<clinit>(OAuth2ResourceServerConfiguration.java:110)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:102)
at org.springframework.context.annotation.ConditionEvaluator.getCondition(ConditionEvaluator.java:120)
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:89)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:217)
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:606)
... 18 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.properties.bind.Bindable
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 29 common frames omitted
这是插件配置:
<!--Swagger Client classes generation-->
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/swagger-api-v1.json</inputSpec>
<language>spring</language>
<library>spring-cloud</library>
<output>${project.build.directory}/generated-sources</output>
<apiPackage>${default.package}.handler</apiPackage>
<modelPackage>${default.package}.model</modelPackage>
<invokerPackage>${default.package}.handler</invokerPackage>
</configuration>
</execution>
</executions>
</plugin>
我正在使用Spring Boot 1.5.9.RELEASE
。 Spring Cloud版本Edgware.RELEASE
。
Api requiers OAuth2 - Application-Only Authentication
为此,我添加了:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
</dependency>
版本是否有问题?
我应该添加哪些依赖项才能使用Feign和OAuth2生成客户端类。
这是swagger文件的摘录:
"securityDefinitions": {
"orange-developer": {
"type": "oauth2",
"flow": "application",
"tokenUrl": "https://api.myApp.com/oauth/v2/token",
"scopes": {
"crs": "Api Services"
}
}
},
"security": [
{
"myApp-developer": [
"crs"
]
}
],