▣ Framework/Spring Boot🍀

    [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-..

    [SpringBoot] REST API 활용하여 CUD 처리 [INSERT, UPDATE, DELETE]

    [SpringBoot] GetMapping, PostMapping [예외처리로 에러 방지하기] [SpringBoot] JDBC Template : SELECT [REST API 적용하여 데이터 조회하기] [SpringBoot] Spring JDBC 사용하여 데이터베이스 연결하기 [JDBC Template, Groovy 활용] [SpringBoot] Service 생성 및 의존성 주입 [생성자 주입을 yermi.tistory.com - REST API 활용하여 CUD 처리 1. INSERT : cityAdd @PostMapping(value="cityAdd") public ResponseEntity cityAdd(@RequestBody City city) { try { log.info("city = {}"..