Spring framework4 [Spring] st_distance_sphere을 사용하여 위치기반 조회 구현 당근의 내 동네 설정같이, 내 위치를 기반으로 반경 2~ 5km의 서비스를 조회하는것을 구현하였다. SET @location = POINT(127.0752881, 37.4921615); desc products; SELECT * FROM products WHERE ST_Distance_Sphere(@location, POINT(longitude, latitude)) entity = null; switch (target) { case PRODUCT: entity = QProduct.product; break; case CLUB: entity = QClub.club; break; case POST: entity = QPost.post; break; default: throw new Exception("잘못된.. 2023. 12. 17. [Spring] @Value 어노테이션 사용시 Access key cannot be null Amazon S3의 설정값을 application-properties에 지정하고, S3Config 클래스를 작성했다. @Configuration @Getter public class S3Config { @Value("${ncloud.endPoint}") private String endPoint; @Value("${ncloud.regionName}") private String regionName; @Value("${ncloud.accessKey}") private String accessKey; @Value("${ncloud.secretKey}") private String secretKey; @Value("${ncloud.bucketName}") private String bucketName; fin.. 2023. 12. 2. [Spring] Dependency Injection (의존성 주입) 정리 DI란 외부에서 두 객체 간의 관계를 결정해주는 디자인 패턴으로, 인터페이스를 사이에 둬서 클래스 레벨에서는 의존관계가 고정되지 않도록 하고 런타임 시에 관계를 동적으로 주입하여 유연성을 확보하고 결합도를 낮출 수 있게 해준다. public class Zoo{ private Tiger tiger; public Zoo(){ this.tiger = new Tiger(); } } 위에 클래스는 Zoo와 Tiger 클래스가 강하게 결합되 있고, 클래스간의 관계가 맺어있다. 동물원에 새로운 동물이 들어오면 생성자 변경은 필수이다. 그리고 Tiger라는 클래스는 너무 구체적이다. 동물원에 들어오는 동물이 호랑인지 기린인지 몰라도 Animal이라는 인터페이스를 사용하여 추상적으로 구현할 필요가 있다. public i.. 2023. 10. 1. [Spring] @Controller와 @RestController의 차이 @Component component-scan을 xml에 정의함으로 빈으로 등록될 준비가 된 클래스들을 스캔하고, @Component Annotation이 있는 클래스에 대하여 bean 인스턴스를 생성한다. @Component 어노테이션을 구체화 한 @Controller, @Service, @Repository 등이 있다. 명시한 클래스가 Controller/Service/Repository로 사용됨을 Spring Framework에 알린다. Controller 클래스에 @Controller 어노테이션을 작성하여 해당 클래스가 Controller로 사용된다는것을 알린다. @Controller 주로 View를 제공하기 위해 사용. @Controller로 지정된 클래스의 메서드는 ViewResolver를 통.. 2023. 9. 6. 이전 1 다음