JAVA-17818 Split or move spring-cloud-openfeign module (conti-2) (#13485)

Co-authored-by: timis1 <noreplay@yahoo.com>
This commit is contained in:
timis1 2023-02-20 18:18:26 +02:00 committed by GitHub
parent 639de9687e
commit 09382f545e
42 changed files with 269 additions and 140 deletions

View File

@ -7,3 +7,8 @@ This module contains articles about Feign
- [Intro to Feign](https://www.baeldung.com/intro-to-feign)
- [Retrying Feign Calls](https://www.baeldung.com/feign-retry)
- [Setting Request Headers Using Feign](https://www.baeldung.com/java-feign-request-headers)
- [File Upload With Open Feign](https://www.baeldung.com/java-feign-file-upload)
- [Feign Logging Configuration](https://www.baeldung.com/java-feign-logging)
- [Retrieve Original Message From Feign ErrorDecoder](https://www.baeldung.com/feign-retrieve-original-message)
- [RequestLine with Feign Client](https://www.baeldung.com/feign-requestline)
- [Propagating Exceptions With OpenFeign and Spring](https://www.baeldung.com/spring-openfeign-propagate-exception)

View File

@ -64,6 +64,22 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.github.openfeign.form</groupId>
<artifactId>feign-form-spring</artifactId>
<version>${feign.form.spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>${spring.cloud.openfeign.version}</version>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<version>${wire.mock.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
@ -118,6 +134,9 @@
<properties>
<feign.version>11.8</feign.version>
<wsdl4j.version>1.6.3</wsdl4j.version>
<feign.form.spring.version>3.8.0</feign.form.spring.version>
<spring.cloud.openfeign.version>3.1.2</spring.cloud.openfeign.version>
<wire.mock.version>2.33.2</wire.mock.version>
</properties>
</project>

View File

@ -0,0 +1,16 @@
package com.baeldung.core;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableFeignClients
public class ExampleApplication {
public static void main(String[] args) {
SpringApplication.run(ExampleApplication.class, args);
}
}

View File

@ -1,6 +1,7 @@
package com.baeldung.cloud.openfeign.client;
package com.baeldung.core.client;
import com.baeldung.core.model.Employee;
import com.baeldung.cloud.openfeign.model.Employee;
import feign.Headers;
import feign.Param;
import feign.RequestLine;

View File

@ -0,0 +1,13 @@
package com.baeldung.core.client;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import com.baeldung.core.config.FeignConfig;
@FeignClient(name = "user-client", url="https://jsonplaceholder.typicode.com", configuration = FeignConfig.class)
public interface UserClient {
@GetMapping(value = "/users")
String getUsers();
}

View File

@ -1,7 +1,8 @@
package com.baeldung.cloud.openfeign.config;
package com.baeldung.core.config;
import org.springframework.context.annotation.Bean;
import feign.Logger;
import org.springframework.context.annotation.Bean;
public class FeignConfig {

View File

@ -1,13 +1,15 @@
package com.baeldung.cloud.openfeign.controller;
package com.baeldung.core.controller;
import com.baeldung.cloud.openfeign.client.EmployeeClient;
import com.baeldung.cloud.openfeign.model.Employee;
import feign.Feign;
import feign.form.spring.SpringFormEncoder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baeldung.core.client.EmployeeClient;
import com.baeldung.core.model.Employee;
import feign.Feign;
import feign.form.spring.SpringFormEncoder;
@RestController
public class EmployeeController {

View File

@ -1,13 +1,13 @@
package com.baeldung.cloud.openfeign.customizederrorhandling.client;
import com.baeldung.cloud.openfeign.customizederrorhandling.config.FeignConfig;
import com.baeldung.cloud.openfeign.defaulterrorhandling.model.Product;
package com.baeldung.core.customizederrorhandling.client;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.baeldung.core.customizederrorhandling.config.FeignConfig;
import com.baeldung.core.defaulterrorhandling.model.Product;
@FeignClient(name = "product-client-2", url = "http://localhost:8081/product/", configuration = FeignConfig.class)
public interface ProductClient {

View File

@ -1,8 +1,9 @@
package com.baeldung.cloud.openfeign.customizederrorhandling.config;
package com.baeldung.core.customizederrorhandling.config;
import com.baeldung.core.customizederrorhandling.exception.ProductNotFoundException;
import com.baeldung.core.customizederrorhandling.exception.ProductServiceNotAvailableException;
import com.baeldung.core.exception.BadRequestException;
import com.baeldung.cloud.openfeign.exception.BadRequestException;
import com.baeldung.cloud.openfeign.customizederrorhandling.exception.ProductNotFoundException;
import com.baeldung.cloud.openfeign.customizederrorhandling.exception.ProductServiceNotAvailableException;
import feign.Response;
import feign.codec.ErrorDecoder;

View File

@ -1,8 +1,9 @@
package com.baeldung.cloud.openfeign.customizederrorhandling.config;
package com.baeldung.core.customizederrorhandling.config;
import org.springframework.context.annotation.Bean;
import feign.Logger;
import feign.codec.ErrorDecoder;
import org.springframework.context.annotation.Bean;
public class FeignConfig {

View File

@ -1,12 +1,13 @@
package com.baeldung.cloud.openfeign.customizederrorhandling.controller;
package com.baeldung.core.customizederrorhandling.controller;
import com.baeldung.cloud.openfeign.customizederrorhandling.client.ProductClient;
import com.baeldung.cloud.openfeign.defaulterrorhandling.model.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baeldung.core.customizederrorhandling.client.ProductClient;
import com.baeldung.core.defaulterrorhandling.model.Product;
@RestController("product_controller2")
@RequestMapping(value = "myapp2")

View File

@ -1,10 +1,11 @@
package com.baeldung.cloud.openfeign.customizederrorhandling.exception;
package com.baeldung.core.customizederrorhandling.exception;
import java.util.Date;
import org.springframework.http.HttpStatus;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.http.HttpStatus;
import java.util.Date;
public class ErrorResponse {

View File

@ -1,6 +1,5 @@
package com.baeldung.cloud.openfeign.customizederrorhandling.exception;
package com.baeldung.core.customizederrorhandling.exception;
import com.baeldung.cloud.openfeign.exception.BadRequestException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;

View File

@ -1,4 +1,4 @@
package com.baeldung.cloud.openfeign.customizederrorhandling.exception;
package com.baeldung.core.customizederrorhandling.exception;
public class ProductNotFoundException extends RuntimeException {

View File

@ -1,4 +1,4 @@
package com.baeldung.cloud.openfeign.customizederrorhandling.exception;
package com.baeldung.core.customizederrorhandling.exception;
public class ProductServiceNotAvailableException extends RuntimeException {

View File

@ -1,13 +1,13 @@
package com.baeldung.cloud.openfeign.defaulterrorhandling.client;
import com.baeldung.cloud.openfeign.defaulterrorhandling.config.FeignConfig;
import com.baeldung.cloud.openfeign.defaulterrorhandling.model.Product;
package com.baeldung.core.defaulterrorhandling.client;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.baeldung.core.defaulterrorhandling.config.FeignConfig;
import com.baeldung.core.defaulterrorhandling.model.Product;
@FeignClient(name = "product-client", url = "http://localhost:8084/product/", configuration = FeignConfig.class)
public interface ProductClient {

View File

@ -1,7 +1,8 @@
package com.baeldung.cloud.openfeign.defaulterrorhandling.config;
package com.baeldung.core.defaulterrorhandling.config;
import org.springframework.context.annotation.Bean;
import feign.Logger;
import org.springframework.context.annotation.Bean;
public class FeignConfig {

View File

@ -1,10 +1,13 @@
package com.baeldung.cloud.openfeign.defaulterrorhandling.controller;
package com.baeldung.core.defaulterrorhandling.controller;
import com.baeldung.cloud.openfeign.defaulterrorhandling.client.ProductClient;
import com.baeldung.cloud.openfeign.defaulterrorhandling.model.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baeldung.core.defaulterrorhandling.client.ProductClient;
import com.baeldung.core.defaulterrorhandling.model.Product;
@RestController("product_controller1")
@RequestMapping(value ="myapp1")

View File

@ -1,4 +1,4 @@
package com.baeldung.cloud.openfeign.defaulterrorhandling.model;
package com.baeldung.core.defaulterrorhandling.model;
public class Product {

View File

@ -0,0 +1,21 @@
package com.baeldung.core.exception;
public class BadRequestException extends Exception {
public BadRequestException() {
}
public BadRequestException(String message) {
super(message);
}
public BadRequestException(Throwable cause) {
super(cause);
}
@Override
public String toString() {
return "BadRequestException: "+getMessage();
}
}

View File

@ -0,0 +1,18 @@
package com.baeldung.core.exception;
public class NotFoundException extends Exception {
public NotFoundException(String message) {
super(message);
}
public NotFoundException(Throwable cause) {
super(cause);
}
@Override
public String toString() {
return "NotFoundException: " + getMessage();
}
}

View File

@ -1,4 +1,4 @@
package com.baeldung.cloud.openfeign.fileupload.config;
package com.baeldung.core.fileupload.config;
public class ExceptionMessage {
private String timestamp;

View File

@ -1,6 +1,5 @@
package com.baeldung.cloud.openfeign.fileupload.config;
package com.baeldung.core.fileupload.config;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.support.SpringEncoder;
import org.springframework.context.annotation.Bean;
@ -13,12 +12,7 @@ import feign.form.spring.SpringFormEncoder;
public class FeignSupportConfig {
@Bean
public Encoder multipartFormEncoder() {
return new SpringFormEncoder(new SpringEncoder(new ObjectFactory<HttpMessageConverters>() {
@Override
public HttpMessageConverters getObject() {
return new HttpMessageConverters(new RestTemplate().getMessageConverters());
}
}));
return new SpringFormEncoder(new SpringEncoder(() -> new HttpMessageConverters(new RestTemplate().getMessageConverters())));
}
@Bean

View File

@ -1,10 +1,10 @@
package com.baeldung.cloud.openfeign.fileupload.config;
package com.baeldung.core.fileupload.config;
import java.io.IOException;
import java.io.InputStream;
import com.baeldung.cloud.openfeign.exception.BadRequestException;
import com.baeldung.cloud.openfeign.exception.NotFoundException;
import com.baeldung.core.exception.BadRequestException;
import com.baeldung.core.exception.NotFoundException;
import com.fasterxml.jackson.databind.ObjectMapper;
import feign.Response;
@ -15,7 +15,7 @@ public class RetreiveMessageErrorDecoder implements ErrorDecoder {
@Override
public Exception decode(String methodKey, Response response) {
ExceptionMessage message = null;
ExceptionMessage message;
try (InputStream bodyIs = response.body()
.asInputStream()) {
ObjectMapper mapper = new ObjectMapper();

View File

@ -1,4 +1,4 @@
package com.baeldung.cloud.openfeign.fileupload.controller;
package com.baeldung.core.fileupload.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.baeldung.cloud.openfeign.fileupload.service.UploadService;
import com.baeldung.core.fileupload.service.UploadService;
@RestController
public class FileController {

View File

@ -1,4 +1,4 @@
package com.baeldung.cloud.openfeign.fileupload.service;
package com.baeldung.core.fileupload.service;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import com.baeldung.cloud.openfeign.fileupload.config.FeignSupportConfig;
import com.baeldung.core.fileupload.config.FeignSupportConfig;
@FeignClient(name = "file", url = "http://localhost:8081", configuration = FeignSupportConfig.class)
public interface UploadClient {

View File

@ -1,4 +1,4 @@
package com.baeldung.cloud.openfeign.fileupload.service;
package com.baeldung.core.fileupload.service;
import org.springframework.web.multipart.MultipartFile;

View File

@ -1,4 +1,4 @@
package com.baeldung.cloud.openfeign.fileupload.service;
package com.baeldung.core.fileupload.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

View File

@ -1,4 +1,4 @@
package com.baeldung.cloud.openfeign.model;
package com.baeldung.core.model;
public class Employee {

View File

@ -5,3 +5,5 @@ ws.port.type.name=UsersPort
ws.target.namespace=http://www.baeldung.com/springbootsoap/feignclient
ws.location.uri=http://localhost:${server.port}/ws/users/
debug=false
logging.level.com.baeldung.core=DEBUG

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
<logger name="feign.Logger" level="DEBUG" />
</appender>
<root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="LOGS" value="./logs" />
<appender name="Console"
class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</layout>
</appender>
<appender name="RollingFile"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOGS}/spring-boot-logger.log</file>
<encoder
class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d %p %C{1.} [%t] %m%n</Pattern>
</encoder>
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily and when the file reaches 10 MegaBytes -->
<fileNamePattern>${LOGS}/archived/spring-boot-logger-%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<!-- LOG everything at INFO level -->
<root level="info">
<appender-ref ref="RollingFile" />
<appender-ref ref="Console" />
</root>
<!-- LOG "com.baeldung*" at TRACE level -->
<logger name="com.baeldung" level="trace" additivity="false">
<appender-ref ref="RollingFile" />
<appender-ref ref="Console" />
</logger>
</configuration>

View File

@ -1,4 +1,4 @@
package com.baeldung.cloud.openfeign;
package com.baeldung.core;
import java.io.File;
import java.io.FileInputStream;
@ -14,10 +14,10 @@ import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.multipart.MultipartFile;
import com.baeldung.cloud.openfeign.fileupload.service.UploadService;
import com.baeldung.core.fileupload.service.UploadService;
@RunWith(SpringRunner.class)
@SpringBootTest
@SpringBootTest(classes = ExampleApplication.class)
public class OpenFeignFileUploadLiveTest {
@Autowired

View File

@ -1,8 +1,12 @@
package com.baeldung.cloud.openfeign.customizederrorhandling.client;
package com.baeldung.core.customizederrorhandling.client;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.configureFor;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static org.junit.Assert.assertThrows;
import com.baeldung.cloud.openfeign.customizederrorhandling.exception.ProductNotFoundException;
import com.baeldung.cloud.openfeign.customizederrorhandling.exception.ProductServiceNotAvailableException;
import com.github.tomakehurst.wiremock.WireMockServer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -11,11 +15,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static org.junit.Assert.assertThrows;
import com.baeldung.core.ExampleApplication;
import com.baeldung.core.customizederrorhandling.exception.ProductNotFoundException;
import com.baeldung.core.customizederrorhandling.exception.ProductServiceNotAvailableException;
import com.github.tomakehurst.wiremock.WireMockServer;
@RunWith(SpringRunner.class)
@SpringBootTest
@SpringBootTest(classes = ExampleApplication.class)
public class ProductClientUnitTest {
@Autowired

View File

@ -1,10 +1,13 @@
package com.baeldung.cloud.openfeign.customizederrorhandling.controller;
package com.baeldung.core.customizederrorhandling.controller;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.configureFor;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static org.junit.Assert.assertEquals;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import com.baeldung.cloud.openfeign.customizederrorhandling.client.ProductClient;
import com.baeldung.cloud.openfeign.customizederrorhandling.exception.ErrorResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.client.WireMock;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -18,10 +21,11 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static org.junit.Assert.assertEquals;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import com.baeldung.core.customizederrorhandling.client.ProductClient;
import com.baeldung.core.customizederrorhandling.exception.ErrorResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.client.WireMock;
@RunWith(SpringRunner.class)

View File

@ -1,8 +1,13 @@
package com.baeldung.cloud.openfeign.defaulterrorhandling.client;
package com.baeldung.core.defaulterrorhandling.client;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.configureFor;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import com.baeldung.cloud.openfeign.defaulterrorhandling.model.Product;
import com.github.tomakehurst.wiremock.WireMockServer;
import feign.FeignException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -12,12 +17,14 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpStatus;
import org.springframework.test.context.junit4.SpringRunner;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import com.baeldung.core.ExampleApplication;
import com.baeldung.core.defaulterrorhandling.model.Product;
import com.github.tomakehurst.wiremock.WireMockServer;
import feign.FeignException;
@RunWith(SpringRunner.class)
@SpringBootTest
@SpringBootTest(classes = ExampleApplication.class)
public class ProductClientUnitTest {
@Autowired

View File

@ -1,8 +1,13 @@
package com.baeldung.cloud.openfeign.defaulterrorhandling.controller;
package com.baeldung.core.defaulterrorhandling.controller;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.configureFor;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import com.baeldung.cloud.openfeign.defaulterrorhandling.client.ProductClient;
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.client.WireMock;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -16,10 +21,9 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
import com.baeldung.core.defaulterrorhandling.client.ProductClient;
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.client.WireMock;
@RunWith(SpringRunner.class)
@WebMvcTest(ProductController.class)

View File

@ -1,11 +1,12 @@
package com.baeldung.cloud.openfeign.defaulterrorhandling.controller;
package com.baeldung.core.defaulterrorhandling.controller;
import feign.FeignException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import feign.FeignException;
@RestControllerAdvice
public class TestControllerAdvice {

View File

@ -2,9 +2,5 @@
- [Introduction to Spring Cloud OpenFeign](https://www.baeldung.com/spring-cloud-openfeign)
- [Differences Between Netflix Feign and OpenFeign](https://www.baeldung.com/netflix-feign-vs-openfeign)
- [File Upload With Open Feign](https://www.baeldung.com/java-feign-file-upload)
- [Feign Logging Configuration](https://www.baeldung.com/java-feign-logging)
- [Provide an OAuth2 Token to a Feign Client](https://www.baeldung.com/spring-cloud-feign-oauth-token)
- [Retrieve Original Message From Feign ErrorDecoder](https://www.baeldung.com/feign-retrieve-original-message)
- [RequestLine with Feign Client](https://www.baeldung.com/feign-requestline)
- [Propagating Exceptions With OpenFeign and Spring](https://www.baeldung.com/spring-openfeign-propagate-exception)

View File

@ -61,12 +61,6 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<version>2.33.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>

View File

@ -1,13 +0,0 @@
package com.baeldung.cloud.openfeign.client;
import com.baeldung.cloud.openfeign.config.FeignConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@FeignClient(name = "user-client", url="https://jsonplaceholder.typicode.com", configuration = FeignConfig.class)
public interface UserClient {
@RequestMapping(value = "/users", method = RequestMethod.GET)
String getUsers();
}