I use microservices based on Springboot 2.4.4. My core service has the next dependencies:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<!--Spring Cloud-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-spring-boot-starter</artifactId>
<version>1.7.30</version>
</dependency>
My RestController:
@FeignClient(value = "search", contextId = "article")
@RequestMapping("/api/space/{spaceId}")
public interface SearchArticleController {
@RequestMapping(value = "/article", method = RequestMethod.GET)
PageSearchResponseImpl<ContentSearchResponseDTO> findArticles(@PathVariable Long spaceId,
@RequestBody SearchRequestDTO requestDTO);
Main class:
@EnableFeignClients(basePackages = {"com.example.api", "ru.example.search"})
@EnableDiscoveryClient
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
When i call findArticles i get an answer from another service with th next content:
2021-04-07 21:04:50.075 WARN 104955 --- [io-20200-exec-5] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported]
When i change onto @PostMapping both services all work well. But i need to use @GetMapping