How to generate spring cloud feign client using swagger-codegen-maven-plugin

可紊 提交于 2019-12-07 20:23:47

问题


I want to generate my feign client code using swagger-codegen, but I cannot find the docs which can lead me to do it.

I have a microservice using spring cloud, several api-services using spring-cloud-feign interfaces to request the data.I wish that i can generate the feign client code.

<plugin>
                <groupId>io.swagger</groupId>
                <artifactId>swagger-codegen-maven-plugin</artifactId>
                <version>2.2.3</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>http://localhost:9141/v2/api-docs?group=building-service-api</inputSpec>
                            <language>java</language>
                            <output>${project.build.directory}/generated-sources/swagger</output>
                            <library>feign</library>
                        </configuration>
                    </execution>
                </executions>
            </plugin> 

language/library set to 'java/feign', there are only models without feign client;

language set to 'spring', 'feign' is unsupported library.

I am confused how to generate all my code? There seems to be almost no guideline or doc or demo?


回答1:


Add spring-cloud-starter-feign dependency in your pom.xml and:

<configuration>
    <language>spring</language>
    <library>spring-cloud</library>
</configuration>


来源:https://stackoverflow.com/questions/46019180/how-to-generate-spring-cloud-feign-client-using-swagger-codegen-maven-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!