티스토리 뷰
0. 프로젝트 구조
1. SupplementsRepository.java 인터페이스로 변경
package mandykr.nutrient.repository;
import mandykr.nutrient.entity.Supplements;
import org.springframework.data.jpa.repository.JpaRepository;
public interface SupplementsRepository extends JpaRepository<Supplements, Long> {
}
2. 테스트 코드 수정
package mandykr.nutrient;
import mandykr.nutrient.entity.Supplements;
import mandykr.nutrient.repository.SupplementsRepository;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Commit;
import org.springframework.transaction.annotation.Transactional;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest
@Transactional
class SupplementsRepositoryTests {
@Autowired
SupplementsRepository supplementsRepository;
@Test
@Commit
void save() {
Supplements supplements = new Supplements();
supplements.setName("빌베리 플러스");
Supplements saveSupplements = supplementsRepository.save(supplements);
Supplements findSupplements = supplementsRepository.findById(saveSupplements.getId()).get();
assertThat(supplements.getName()).isEqualTo(findSupplements.getName());
}
}
출처
https://www.inflearn.com/course/스프링부트-JPA-활용-1 실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발(김영한)
728x90
'Spring Boot > 환경설정' 카테고리의 다른 글
[Spring Boot#환경설정] 7. React 연동 (0) | 2021.11.24 |
---|---|
[Spring Boot#환경설정] 6. Querydsl 설정 (0) | 2021.11.24 |
[Spring Boot#환경설정] 4. JPA 설정 (0) | 2021.11.23 |
[Spring Boot#환경설정] 3. Thymeleaf (view) 설정 (0) | 2021.11.23 |
[Spring Boot#환경설정] 2. Spring boot 프로젝트 생성 (0) | 2021.11.23 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- http
- JPA
- 도메인 모델링
- 스프링 카프카 컨슈머
- java8
- MySQL
- TDD
- 클린코드
- 폴링 발행기 패턴
- 학습 테스트
- Spring
- 스프링 예외 추상화
- 마이크로서비스 패턴
- Ubiquitous Language
- ATDD
- HTTP 헤더
- 계층형 아키텍처
- named query
- 육각형 아키텍처
- Spring Boot
- Spring Data JPA
- clean code
- mockito
- 이벤트 스토밍
- Stream
- kafka
- 트랜잭셔널 아웃박스 패턴
- H2
- Git
- spring rest docs
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함