▣ Framework

    [Spring] SOLID란? [객체지향 설계의 5가지 원칙]

    - SOLID란? SOLID는 객체 지향 설계의 다섯 가지 기본 원칙을 나타내는 약어다. 이 다섯 가지 원칙은 소프트웨어의 유지 보수성, 재사용성, 확장성, 테스트 용이성 등을 높이기 위해 고안되었다. 1. SRP(Single Responsibility Principle) : 단일 책임 원칙 클래스는 단 하나의 책임만 가져야 한다는 원칙 각 클래스는 하나의 역할만 수행하고, 변경 사항이 있을 때는 한 가지 이유로만 변경되어야 함 [Spring] SOLID : 객체지향 설계의 5가지 원칙(1) [SRP(Single Responsibility Principle) : 단일 책임 원칙] - SRP(Single Responsibility Principle) : 단일 책임 원칙 단일 책임 원칙은 모든 클래스는 하나..

    [SpringBoot] 스프링 부트(Spring Boot) AOP 적용 [메서드 별 시간 측정하는 로직 추가]

    - 스프링 부트(Spring Boot) AOP 적용 1. 시간 측정 로직 추가 회원 가입 시간, 회원 조회 메서드 시간을 측정하고 싶다면? 더 나아가 모든 메서드의 호출 시간을 측정하고 싶다면 어떻게 해야할까? // 회원가입 public Long join(Member member) { long start = System.currentTimeMillis(); try { validateDuplicateMember(member); //중복 회원 검증 memberRepository.save(member); return member.getId(); } finally { long finish = System.currentTimeMillis(); long timeMs = finish - start; System.ou..

    [SpringBoot] 순수JDBC vs JDBC Template vs JPA [스프링 DB 접근 기술 비교]

    - 순수JDBC vs JDBC Template vs JPA 과거에 사용했던 순수JDBC부터 JDBC Template, JPA, Spring Data JPA까지 DB 활용 코드가 어떻게 변하는지 회원 데이터 저장 및 회원 데이터 조회 코드로 비교해보려고 한다. 1. 순수JDBC 순수JDBC는 Connection 코드부터 PreparedStatement, ResultSet 모두 일일이 호출해줘야 한다. (A부터 Z까지 다 만들어줘야 함) package hello.hellospring.repository; import hello.hellospring.domain.Member; import org.springframework.jdbc.datasource.DataSourceUtils; import javax.sq..

    [SpringBoot] 자바 코드로 직접 스프링 빈 등록하기 [@Configuration를 활용한 Bean 등록]

    - 자바 코드로 직접 스프링 빈 등록하기 실무에서는 주로 정형화된 컨트롤러, 서비스, 리포지토리 같은 코드는 컴포넌트 스캔을 사용한다. 정형화 되지 않거나, 상황에 따라 구현 클래스를 변경해야 하면 설정을 통해 스프링 빈으로 등록한다. (@Service, @Repository, @Autowired 어노테이션을 제거하고 진행해야 함!) package hello.hellospring; import hello.hellospring.repository.MemberRepository; import hello.hellospring.repository.MemoryMemberRepository; import hello.hellospring.service.MemberService; import org.springfram..

    [SpringBoot] 스프링 부트(Spring Boot) 컨텐츠 동작 원리 [정적 컨텐츠, MVC 템플릿 엔진, @ResponseBody 사용

    - 스프링 부트(Spring Boot) 컨텐츠 동작 원리 1. 정적 페이지 스프링 부트에서는 DB 접근을 하지 않는 '정적 페이지'는 static 폴더 안에 넣으면 된다. - 실행 URL : http://localhost:8080/hello-static.html 2. MVC 템플릿 엔진 MVC: Model, View, Controller (데이터를 담는 Model, 화면을 보여주는 View, Model과 View를 연결시키는 Controller) - 실행 URL : http://localhost:8080/hello-mvc?name=spring - Controller 코드 (MVC 템플릿 엔진) @Controller public class HelloController { @GetMapping("hello-..