nodename nor servname provided, or not known executing GET http://ADMIN-API/user/5202

13 Views Asked by At

I'm unable to use feign-client without using url in open-feign client:

This is my app.yaml file:

spring:
  application:
    name: feign-client
  management:
    endpoint:
      health:
        show-details: always
    endpoints:
      web:
        exposure:
          include: health
management:
  endpoints:
    web:
      exposure:
        include: "*"

server:
  port: 8081

eureka:
  server:
    host: localhost:8761
    contextPath: service-registry
  client:
    serviceUrl:
      defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}

admin-api:
  base-url: http://localhost


resilience4j:
  circuitbreaker:
    instances:
      feign-client:
        registerHealthIndicator: true
        failureRateThreshold: 50
        minimumNumberOfCalls: 5
        automaticTransitionFromOpenToHalfOpenEnabled: true
        waitDurationInOpenState: 5s
        permittedNumberOfCallsInHalfOpenState: 3
        slidingWindowSize: 10
        slidingWindowType: COUNT_BASED

This is my service:


@FeignClient(  value = "ADMIN-API")
public interface UserServiceClient {
    Logger logger = LoggerFactory.getLogger(UserServiceClient.class);

    @PostMapping("/users")
    ResponseEntity<?> createUser(@Valid @RequestBody UserModel userModel);
   
    @PutMapping("/users/{userId}")
    ResponseEntity<?> updateUser(@PathVariable Long userId, @Valid @RequestBody UserModel userModel);
   

    @RequestMapping(value = "/users/{userId}",method = RequestMethod.PATCH,consumes = MediaType.APPLICATION_JSON_VALUE,produces = MediaType.TEXT_PLAIN_VALUE)
    ResponseEntity<String> updateUserStatus(@PathVariable Long userId, @RequestParam String status);
    

    @GetMapping("/users/search")
    ResponseEntity<?> getAllUsers(@RequestParam int pageSize, @RequestParam int pageNumber, @RequestBody UserSearch userSearch);
    
    @GetMapping("/user/{userId}")
    ResponseEntity<?> getUserByUserId(@PathVariable(name = "userId") Long userId);
    

}

This is my controller:


@RestController
@RequestMapping("/api/v1/client")
public class UserControllerClient {

    @Autowired
    private UserServiceClient userServiceClient;

    @GetMapping("/users/{userId}")
    public ResponseEntity<?> getUserByUserId(@PathVariable Long userId){
        return userServiceClient.getUserByUserId(userId);
    }

    @PostMapping("/users")
    public ResponseEntity<?> createUser(@Valid @RequestBody UserModel userModel){
        return userServiceClient.createUser(userModel);
    }

    @PutMapping("/users/{userId}")
    public ResponseEntity<?> updateUser(@PathVariable Long userId, @Valid @RequestBody UserModel userModel){
        return userServiceClient.updateUser(userId, userModel);
    }

    @GetMapping("/users/search")
    public ResponseEntity<?> getAllUsers(@RequestParam int pageSize, @RequestParam int pageNumber, @RequestBody UserSearch userSearch){
        return userServiceClient.getAllUsers(pageSize, pageNumber, userSearch);
    }

    @PatchMapping("/users/{userId}")
    public ResponseEntity<?> updateUserStatus(@PathVariable Long userId, @RequestParam String status){
        return userServiceClient.updateUserStatus(userId, status);
    }

}

I don't want to use url in @FeignClient(value = "admin-api", url = "http://localhost:8080/) like this. when i just give without url it throws an error: admin-api: nodename nor servname provided, or not known executing GET http://ADMIN-API/user/5202

0

There are 0 best solutions below