본문 바로가기

SPRING/Spring Boot

(12)
JPA JPA(Java Persistence API) 1. 기존의 반복 코드는 물론이고, 기본적인 SQL도 JPA가 직접 만들어서 실행해준다. 2. JPA를 사용하면, SQL과 데이터 중심의 설계에서 객체 중심의 설계로 패러다임을 전환을 할 수 있다. 3. JPA를 사용하면 개발 생산성을 크게 높일 수 있다. JPA는 인터페이스다! 구현체로 hibernate, eclipse 등이 있다. JPA는 자바진영의 표준 인터페이스. 참고하여 공부할 블로그 https://velog.io/@adam2/JPA%EB%8A%94-%EB%8F%84%EB%8D%B0%EC%B2%B4-%EB%AD%98%EA%B9%8C-orm-%EC%98%81%EC%86%8D%EC%84%B1-hibernate-spring-data-jpa JPA는 도대체..
[스프링 통합테스트] @Spring, @Transactional package hifive.hifivespring.service; import hifive.hifivespring.domain.Member; import hifive.hifivespring.repository.MemberRepository; import hifive.hifivespring.repository.MemoryMemberRepository; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframe..
[회원 웹 기능] - 홈 화면 추가 Hello Spring 회원 기능 회원 가입 회원 목록 package hifive.hifivespring.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; @Controller public class HomeController { @GetMapping("/") public String home() { return "home"; } } ** 정적 컨텐츠 이미지 먼저 요청이 오면 스프링 컨테이너안에 관련 컨트롤러가 있는지 찾는다. 없으면 static파일을 찾기 때문이다. 그렇기때문에 HomeController에 매핑되어있는 것이 있기때문에 ho..
스프링 빈과 의존관계 - 자바 코드로 직접 스프링 빈 등록 회원 서비스와 회원 리포지토리의 @Service, @Repository, @Autowired 애노테이션을 제거하고, SpringConfig를 만들어 직접 스프링 빈을 등록 package hifive.hifivespring; import hifive.hifivespring.repository.MemberRepository; import hifive.hifivespring.repository.MemoryMemberRepository; import hifive.hifivespring.service.MemberService; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configu..
스프링 빈과 의존관계 - 컴포넌트 스캔 *회원 컨트롤러에 의존관계 추가 package hello.hellospring.controller; import hello.hellospring.service.MemberService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @Controller public class MemberController { private final MemberService memberService; @Autowired public MemberController(MemberService memberService) { this.memberService = memberS..
[회원 리포지토리 테스트 케이스 작성] 회원 리포지토리 테스트 케이스 작성 개발한 기능을 실행해서 테스트 할 때 자바의 main 메서드를 통해서 실행하거나, 웹 애플리케이션의 컨트롤러를 통해서 해당 기능을 실행한다. 이러한 방법은 준비하고 실행하는데 오래 걸리고, 반복 실행하기 어렵고 여러 테스트를 한번에 실행하기 어렵다는 단점이 있다. 자바는 JUnit이라는 프레임워크로 테스트를 실행해서 이러한 문제를 해결한다 package hifive.hifivespring.repository; import hifive.hifivespring.domain.Member; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter..
[회원관리 예제] Back-End Develop 1. 비즈니스 요구사항 정리 - 데이터: 회원 ID, 이름 - 기능: 회원 등록, 조회 - 아직 데이터 저장소가 선정되지 않음(가상의 시나리오) 컨트롤러: 웹 MVC의 컨트롤러 역할 서비스: 핵심 비즈니스 로직 구현 (중복 가입 안됨 등등의 서비스 포함) 리포지토리: 데이터베이스에 접근, 도메인 객체를 DB에 저장하고 관리도메인: 비즈니스 도메인 객체 (예: 회원, 주문, 쿠폰 등등 주로 데이터베이스에 저장하고 관리 됨) 아직 데이터 저장소가 선정되지 않아서, 우선 인터페이스로 구현 클래스를 변경할 수 있도록 설계.데이터 저장소는 RDB, NoSQL 등등 다양한 저장소를 고민중인 상황으로 가정 개발을 진행하기 위해서 초기개발 단계에서는 구현체로 가벼운 메모리 기반의 데이터 저장소 사용 2. 회원 리포지토..
[Gradle] Gralde 빌드(2) --> jar 실행 1. build > libs cd build//해당 폴더로 이동 dir // ls == dir 폴더 안 목록 cd libs 2. libs> dir D:\hifiveProject\hifive-spring\build\libs> dir 3. java 실행 java -jar hifive-spring-0.0.1-SNAPSHOT.jar Q. IntelliJ로 했는데 cmd로 빌드 하는 이유는 무엇일까? A. 실무에서 개발 할 때 서버에서 빌드를 하는 경우도 많이있다. 서버에서는 cmd만 활용하여 작업하기 때문에 cmd로 빌드 하는 방법을 알아두어야한다. jar 실행 종류 단축키 Ctrl + c