我想减少Feign.builder()样板重复代码

时间:2019-03-06 12:42:53

标签: boilerplate spring-cloud-feign netflix-feign

我在我的feign.builder()中声明了Stepdefs.class三遍 是否有减少代码行数的方法? 即时消息是我自己学习的,因此如何使以下代码更可重用。

      Interface.PostComment postComment = Feign.builder()
                    .client(new OkHttpClient())
                    .encoder(new JacksonEncoder())
                    .decoder(new JacksonDecoder())
                    .logger(new Slf4jLogger(Interface.PostComment.class))
                    .logLevel(Logger.Level.FULL)
                    .target(Interface.PostComment.class, "http://localhost:3000/comments/");

        Interface.DeleteComment deleteComment = Feign.builder()
                        .client(new OkHttpClient())
                        .encoder(new JacksonEncoder())
                        .decoder(new JacksonDecoder())
                        .logger(new Slf4jLogger(Interface.DeleteComment.class))
                        .logLevel(Logger.Level.FULL)
                        .target(Interface.DeleteComment.class, "http://localhost:3000/comments/" + id );


        Interface.UpdateComment updateComment= Feign.builder()
                        .client(new OkHttpClient())
                        .encoder(new JacksonEncoder())
                        .decoder(new JacksonDecoder())
                        .logger(new Slf4jLogger(Interface.UpdateComment.class))
                        .logLevel(Logger.Level.FULL)
                        .target(Interface.UpdateComment.class, "http://localhost:3000/comments/" + id);

0 个答案:

没有答案