본문 바로가기

Spring106

[스프링 입문] 스프링 통합 테스트 스프링 컨테이너와 DB까지 연결한 통합 테스트 회원 서비스 스프링 통합 테스트 package hello.hellospring.service; import hello.hellospring.domain.Member; import hello.hellospring.repository.MemberRepository; import hello.hellospring.repository.MemoryMemberRepository; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework... 2021. 9. 1.
[스프링 입문] 순수 JDBC 환경 설정 build.gradle 파일에 jdbc, h2 데이터베이스 관련 라이브러리 추가 implementation 'org.springframework.boot:spring-boot-starter-jdbc' runtimeOnly 'com.h2database:h2' 스프링 부트 데이터베이스 연결 설정 추가 spring.datasource.url=jdbc:h2:tcp://localhost/~/test spring.datasource.driver-class-name=org.h2.Driver spring.datasource.username=sa 주의!: 스프링부트 2.4부터는 spring.datasource.username=sa를 꼭 추가해주어야 합니다. 그렇지 않으면 Wrong user name or pa.. 2021. 8. 31.
[스프링 입문] H2 데이터베이스 설치 개발이나 테스트 용도로 가볍고 편리한 DB, 웹 화면 제공 https://www.h2database.com/ 다운로드 및 설치 h2 데이터베이스 버전은 스프링 부트 버전에 맞춥니다. 권한 주기: chmod 755 h2.sh(윈도우 사용자는 x) 실행: ./h2.sh(윈도우 사용자는 h2.bat) 데이터베이스 파일 생성 방법 jdbc:h2:~/test(최초 한번) ~/test.mv.db 파일 생성 확인 이후부터는 jdbc:h2:tcp://localhost/~/test 이렇게 접속 테이블 생성하기 테이블 관리를 위해 프로젝트 루트에 sql/ddl.sql 파일을 생성 drop table if exists member CASCADE; create table member ( id bigint generated b.. 2021. 8. 31.
[스프링 입문] 회원 웹 기능 - 조회 회원 컨트롤러에서 조회 기능 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... 2021. 8. 31.