AOP가 필요한 상황

기록/스프링부트 시작하기 2020. 12. 23. 16:35

모든 메소드의 호출 시간을 측정하고 싶다면? 공통 관심 사항(Cross-Cutting Concern) vs 핵심 관심 사항(Core Concern) 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.out.println("join = " + timeMs + "..

Article Thumbnail
스프링 DB접근 기술 - Spring Data JPA

기록/스프링부트 시작하기 2020. 12. 23. 15:45

JPA (JAVA Persistence API) • 자바 어플리케이션에서 관계형 데이터베이스를 사용하는 방식을 정의한 인터페이스 • 기존의 반복 코드는 물론 , 기본적인 SQL도 JPA가 직접 만들어서 실행해준다. • JPA 인터페이스 write-read.tistory.com 스프링 부트와 JPA만 사용해도 개발 생산성이 정말 많이 증가하고 , 개발해야할 코드도 확연히 줄어든다. 여기에 Spring Data JPA를 사용하면 , 기존의 한계를 넘어 마치 마법처럼 , 리포지토리에 구현 클래스 없이 인터페이스만으로 개발을 완료할 수 있다. 그리고 반복 개발해온 기본 CRUD 기능도 Spring Data JPA가 모두 제공한다. 따라서 개발자는 핵심 비즈니스 로직을 개발하는데 집중할 수 있다. 실무에서 관계형..

Article Thumbnail
스프링 DB접근 기술 - JPA(Entity Manager - Raw JPA)

기록/스프링부트 시작하기 2020. 12. 23. 14:39

JPA (JAVA Persistence API) • 자바 어플리케이션에서 관계형 데이터베이스를 사용하는 방식을 정의한 인터페이스 • 기존의 반복 코드는 물론 , 기본적인 SQL도 JPA가 직접 만들어서 실행해준다. • JPA 인터페이스 write-read.tistory.com build.grlade 수정 dependencies { implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' //implementation 'org.springframework.boot:spring-boot-starter-jdbc' imple..

스프링 DB접근 기술 - JdbcTemplate

기록/스프링부트 시작하기 2020. 12. 23. 00:28

순수 Jdbc와 동일한 환경설정을 하면 된다. 스프링 DB접근 기술 - 순수JDBC 순수 JDBC (주의! 이렇게 JDBC API로 직접 코딩하는 것은 20년 전 이야기이다. 참고만 하고 넘어가자) build.gradle 라이브러리 추가 dependencies { implementation 'org.springframework.boot:spring-boot-start.. write-read.tistory.com 스프링 JdbcTemplate과 MyBatis같은 라이브러리는 JDBC API에서 본 반복 코드를 대부분 제거해준다. 하지만 SQL은 직접 작성해야한다 JdbcTemplateMemberRepository package hello.hellospring.repository; import hello.h..

Article Thumbnail
스프링 DB접근 기술 - 스프링 통합 테스트

기록/스프링부트 시작하기 2020. 12. 22. 23:44

스프링 컨테이너와 DB까지 연결한 통합 테스트를 진행 MemberServiceIntegrationTest package hello.hellospring.service; import hello.hellospring.domain.Member; import hello.hellospring.repository.MemberRepository; import hello.hellospring.repository.MemoryMemberRepository; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api...

Article Thumbnail
스프링 DB접근 기술 - 순수JDBC

기록/스프링부트 시작하기 2020. 12. 22. 23:06

순수 JDBC (주의! 이렇게 JDBC API로 직접 코딩하는 것은 20년 전 이야기이다. 참고만 하고 넘어가자) build.gradle 라이브러리 추가 dependencies { implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-jdbc' runtimeOnly 'com.h2database:h2' testImplementation 'org.springframework.boot:spring-boot-sta..

Article Thumbnail
회원 웹 기능

기록/스프링부트 시작하기 2020. 12. 21. 16:32

MemberController package hello.hellospring.controller; import hello.hellospring.domain.Member; import hello.hellospring.service.MemberService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation..

Article Thumbnail
스프링 빈과 의존관계

기록/스프링부트 시작하기 2020. 12. 21. 16:24

회원관리 예제 - Repository개발 및 테스트 케이스 작성 데이터 : 회원 ID, 이름 기능 : 회원 등록 , 조회 MemberRepository.java (Interface) package hello.hellospring.repository; import hello.hellospring.domain.Member; import java.util.List; import java.uti.. write-read.tistory.com 회원관리 예제 - Service개발 및 테스트 케이스 작성 회원관리 예제 - Repository개발 및 테스트 케이스 작성 데이터 : 회원 ID, 이름 기능 : 회원 등록 , 조회 MemberRepository.java (Interface) package hello.hello..

Article Thumbnail
회원관리 예제 - Service개발 및 테스트 케이스 작성

기록/스프링부트 시작하기 2020. 12. 21. 15:26

회원관리 예제 - Repository개발 및 테스트 케이스 작성 데이터 : 회원 ID, 이름 기능 : 회원 등록 , 조회 MemberRepository.java (Interface) package hello.hellospring.repository; import hello.hellospring.domain.Member; import java.util.List; import java.uti.. write-read.tistory.com Service package hello.hellospring.service; import hello.hellospring.domain.Member; import hello.hellospring.repository.MemberRepository; import hello.hell..

Article Thumbnail
회원관리 예제 - Repository개발 및 테스트 케이스 작성

기록/스프링부트 시작하기 2020. 12. 20. 16:13

데이터 : 회원 ID, 이름 기능 : 회원 등록 , 조회 MemberRepository.java (Interface) package hello.hellospring.repository; import hello.hellospring.domain.Member; import java.util.List; import java.util.Optional; public interface MemberRepository { Member save(Member member); Optional findById(Long id); Optional findByName(String name); List findAll(); } MemoryMemberRepository.java (Implementation) package hello.h..

Article Thumbnail