Spring cloud services – service registry – zoltan altfatter – ingeniero de software localbitcoins login

@SpringBootApplication public class CustomerService {public static void main (String [] args) {SpringApplication. ejecutar (CustomerService. clase, args); } @Configuration clase estática CustomerConfig {@Bean @LoadBalanced public RestTemplate restTemplate () {return new RestTemplate (); }} @RestController @ Slf4j clase estática CustomerController {private static final String TEMPLATE = UriComponentsBuilder. fromUriString ( "//orden-Servicio/pedidos" ) queryParam ( "Identificación del cliente" , "{Identificación del cliente}" ) construir (). toUriString (); final privado RestTemplate restTemplate; repositorio cliente final privado CustomerRepository; Public CustomerController (RestTemplate restTemplate, CustomerRepository customerRepository) {this. restTemplate = restTemplate; esta . customerRepository = customerRepository; } @GetMapping ( "/ customers / {id}" ) public ResponseEntity getCustomer (@PathVariable Long id) {log. información ( "getCustomer with id {}" , carné de identidad ); Customer customer = customerRepository. getCustomer (id); if (customer == null) {return new ResponseEntity (HttpStatus. NOT_FOUND); } Orden orden = restoTemplate. getForObject (PLANTILLA, orden, clase, id); if (order! = null) {cliente. setOrder (orden nuevo (orden. getDetails (), orden. getTime ())); } return new ResponseEntity (cliente, HttpStatus. OK); }} @Data @AllArgsConstructor clase estática Cliente {Identificación larga; Nombre de cadena; Orden orden ; } @Data @NoArgsConstructor @AllArgsConstructor class static Order {String details; Hora LocalDateTime; }}

@SpringBootApplication @EnableFeignClients public class CustomerServiceFeign {public static void main (String [] args) {SpringApplication. ejecutar (CustomerServiceFeign. class, args); } @RestController @ Slf4j clase estática CustomerController {private final OrderServiceClient orderServiceClient; final privado CustomerRepository customerRepository; Public CustomerController (OrderServiceClient orderServiceClient, CustomerRepository customerRepository) {this. orderServiceClient = orderServiceClient; esta . customerRepository = customerRepository; } @GetMapping ( "/ customers / {id}" ) public ResponseEntity getCustomer (@PathVariable Long id) {log. información ( "getCustomer with id {}" , carné de identidad ); Customer customer = customerRepository. getCustomer (id); if (customer == null) {return new ResponseEntity (HttpStatus. NOT_FOUND); } Orden orden = orderServiceClient. getOrder (id); if (order! = null) {cliente. setOrder (orden. getDetails ()); } return new ResponseEntity (cliente, HttpStatus. OK); }} @FeignClient ( "orden-Servicio" ) interfaz OrderServiceClient {@GetMapping ( "/pedidos" ) Pedido getOrder (@RequestParam ( "Identificación del cliente" ) Identificación larga); }}

@SpringBootApplication @EnableAdminServer public class SpringBootAdmin {public static void main (String [] args) {SpringApplication. ejecutar (clase SpringBootAdmin., args); } @Configuration clase estática WebSecurityConfig extiende WebSecurityConfigurerAdapter { final privado String adminContextPath; public WebSecurityConfig (AdminServerProperties adminServerProperties) {this. adminContextPath = adminServerProperties. getContextPath (); } @Override protected void configure (HttpSecurity http) throws Exception {SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler (); successHandler. setDefaultTargetUrl (adminContextPath + "/" ); successHandler. setTargetUrlParameter ( "redirigir a" ); http authorizeRequests (). antMatchers (adminContextPath + "/bienes/**" ) permitAll (). antMatchers (adminContextPath + "/iniciar sesión" ) permitAll (). cualquier solicitud (). autenticado (). y (). formLogin (). loginPage (adminContextPath + "/iniciar sesión" ) successHandler (successHandler). y (). cerrar sesión (). logoutUrl (adminContextPath + "/cerrar sesión" ) y (). httpBasic (). y (). csrf (). desactivar (); }}}

banner