覆盖JH4.x中的SwaggerConfiguration

时间:2017-08-15 13:03:50

标签: jhipster

如何从jhipster SwaggerConfiguration覆盖Docket bean?我需要为我的api添加自定义Docket :: directModelSubstitute。

1 个答案:

答案 0 :(得分:3)

要覆盖SwaggerConfiguration,我将SwaggerConfig类添加到我的项目config / apidocs,它扩展了SwaggerConfiguration和@Override swaggerSpringfoxDocket bean

@Configuration
public class SwaggerConfig extends SwaggerConfiguration {
    private final Logger log = LoggerFactory.getLogger(SwaggerConfig.class);

    @Bean
    @Override
    public Docket swaggerSpringfoxDocket(JHipsterProperties jHipsterProperties) {

最后将SwaggerConfiguration添加到App.java中@EnableAutoConfiguration的排除

@EnableAutoConfiguration(exclude = {MetricFilterAutoConfiguration.class, MetricRepositoryAutoConfiguration.class, SwaggerConfiguration.class})

如果SwaggerConfiguration为swaggerSpringfoxDocket bean设置了@ConditionalOnMissingBean,那将会容易得多。