-
[Spring] 테스트 코드에서의 @Transactional 사용Spring 2023. 5. 30. 22:48
@Transactional 사이드 프로젝트를 진행하며 테스트 코드를 짜던 중 테스트 코드에서 @Transactional를 사용하는 과정에서 문제가 생겨 글을 작성하게 되었다. ❗️ 문제 ScheduleServiceTest.java (일부) @SpringBootTest @Transactional(readOnly = true) class ScheduleServiceTest { @Autowired DatabaseCleanUp databaseCleanUp; @Autowired ScheduleService scheduleService; @BeforeEach @Transactional void beforeEach() { SignUpDto signUpDto1 = SignUpDto.builder() .username(..
-
[Spring] 네이버 도서 검색 API 활용하기Spring 2023. 4. 22. 04:48
네이버 도서 검색 API 활용하기 본 포스팅에서는 네이버 도서 검색 API를 활용하여 client 측에 도서 데이터를 전달하는 서비스를 구현할 것이다. client 측은 thymeleaf template, server 측은 springboot를 사용하였다. 네이버 개발자센터에 애플리케이션 등록 요청 URL 생성 HttpURLConnection으로 데이터 요청하기 응답 데이터 읽어오기 JSON 파싱하기 DTO 구현 Controller 구현 template 구현 javascript 구현 1️⃣ 네이버 개발자센터에 애플리케이션 등록 NAVER Developers 네이버 오픈 API들을 활용해 개발자들이 다양한 애플리케이션을 개발할 수 있도록 API 가이드와 SDK를 제공합니다. 제공중인 오픈 API에는 네이버..
-
[Spring] Spring boot가 자동 등록하는 HandlerMapping과 HandlerAdapterSpring 2023. 3. 14. 00:46
HandlerMapping & HandlerAdapter 스프링부트에 구현되어있는 주요한 HandlerMapping과 HandlerAdapter를 알아보자! 🔎 HandlerMapping 0 = RequestMappingHandlerMapping ➡️ 애노테이션 기반의 컨트롤러인 @RequestMapping에서 사용한다. 1 = BeanNameUrlHandlerMapping ➡️ 스프링 빈의 이름으로 핸들러를 찾는다. 🔎 HandlerAdapter 0 = RequestMappingHandlerAdapter ➡️ 애노테이션 기반의 컨트롤러인 @RequestMapping에서 사용한다. 1 = HttpRequestHandlerAdapter ➡️ HttpRequestHandler를 처리한다. 2 = Simpl..
-
[Spring] Cannot resolve taglib with uri http://java.sun.com/jsp/jstl/coreSpring 2023. 3. 9. 14:02
❗️ 문제 jsp로 view를 구현하던 중, 기능을 사용하고자 taglib를 추가했다가 다음과 같은 오류를 마주했다. ✅ 해결 build.gradle에 추가된 관련 dependency는 아래와 같았다. implementation 'javax.servlet:jstl' spring boot 3.0 이상에서는 이를 제거하고 implementation 'jakarta.servlet:jakarta.servlet-api' implementation 'jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api' implementation 'org.glassfish.web:jakarta.servlet.jsp.jstl' 를 추가해주어야 한다.
-
[Spring] 리소스를 식별하는 통일된 방식 | URI, URL, URNSpring 2023. 3. 2. 14:18
https://www.ietf.org/rfc/rfc3986.txt 1.1.3. URI, URL, and URN A URI can be further classified as a locator, a name, or both. The term "Uniform Resource Locator" (URL) refers to the subset of URIs that, in addition to identifying a resource, provide a means of locating the resource by describing its primary access mechanism (e.g., its network "location"). The term "Uniform Resource Name" (URN) ha..
-
[Spring] SOLID | 좋은 객체 지향 설계의 5가지 원칙Spring 2023. 2. 11. 18:41
SOLID SRP: 단일 책임 원칙 (Single responsibility principle) OCP: 개방-폐쇄 원칙 (Open/closed principle) LSP: 리스코프 치환 원칙 (Liskov substitution principle) ISP: 인터페이스 분리 원칙 (Interface segregation principle) DIP: 의존관계 역전 원칙 (Dependency inversion principle) 1️⃣ SRP 단일 책임 원칙 Single responsibility principle 한 클래스는 하나의 책임만 가져야 한다. 하나의 책임이라는 것은 모호하다. - 클 수 있고, 작을 수 있다. - 문맥과 상황에 따라 다르다. 중요한 기준은 변경이다. 변경이 있을 때 파급 효과가 ..