Skip to content

Instantly share code, notes, and snippets.

View diegosilva13's full-sized avatar
🎯
Focusing

Diego Brener diegosilva13

🎯
Focusing
View GitHub Profile
package com.coderef.delivery.config;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
server:
port: 9092
eureka:
instance:
hostname: localhost
port: 9091
client:
registerWithEureka: true
fetchRegistry: false
server:
port: 9093
eureka:
instance:
hostname: localhost
port: 9091
client:
registerWithEureka: true
fetchRegistry: false
package com.coderef.delivery.security;
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
{
"product": "Apple",
"price": "1.25"
}
package com.coderef.delivery;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
@SpringBootApplication
@EnableEurekaClient
public class DeliveryOrderServiceApplication {
package com.coderef.delivery.exception;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import javax.validation.ConstraintViolationException;
import java.util.stream.Collectors;
package com.coderef.delivery.controller;
import com.coderef.delivery.model.Order;
import com.coderef.delivery.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
package com.coderef.delivery.service;
import com.coderef.delivery.model.Order;
import com.coderef.delivery.repository.OrderRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@Service
public class OrderService {
package com.coderef.delivery.repository;
import com.coderef.delivery.model.Order;
import org.springframework.data.repository.CrudRepository;
public interface OrderRepository extends CrudRepository<Order, Integer> {
}