openFeigin 调用第三方接口的方式

  

 maven引入

        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-core</artifactId>
            <version>10.4.0</version>
        </dependency>
        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-jackson</artifactId>
            <version>9.5.0</version>
        </dependency>

使用

    DataPickClient client = Feign.builder()
                .encoder(new JacksonEncoder())
                .decoder(new JacksonDecoder())
//                .options(new Request.Options(1000, 3500))
//                .retryer(new Retryer.Default(5000, 5000, 3))
                .target(DataPickClient.class, "http://"+dpNode.getHostAddress()+":"+dpNode.getPort());

 AjaxResult tables = client.getTables(dpSource,dpDataSource.getTableSchema());
    

 方法定义

    @RequestLine("POST /metadata/getTables?tableSchema={tableSchema}")
    @Headers("Content-Type: application/json")
    AjaxResult getTables(DpDataSourceDto dpDataSourceDto,@Param("tableSchema") String tableSchema);

    @RequestLine("GET /metadata/getDBSchema")
    @Headers("Content-Type: application/json")
    AjaxResult getDBSchema(@RequestBody DpDataSourceDto dpDataSource);

    @RequestLine("POST /metadata/getColumnInfosBySql?tableSchema={tableSchema}&tableName={tableName}")
    @Headers("Content-Type: application/json")
    JSONObject getColumnInfosBySql(DpDataSourceDto dpSource, @Param("tableSchema") String tableSchema, @Param("tableName") List<String> tableName);

猜你喜欢

转载自blog.csdn.net/qq_43632987/article/details/130144965