해결된 질문
작성
·
314
0
이 강의를 들으며 잘 진행을 해왔는데 데이터베이스 테이블들이 전부 없어졌네요ㅠㅠ
실행을 시키면 마지막에 모든 테이블들이 DROP이 되어버립니다.
답변 5
1
0
0
네^^
jpa -> 앞에 띄어쓰기 2개 필요합니다. yml이 2개 단위로 구조를 만들거든요. spring.jpa 이렇게 되어야 하는 것이지요.
그리고 hibernate 앞에는 4개가 필요합니다^^
spring:
datasource:
url: jdbc:h2:tcp://localhost/~/jpashop
username: sa
password:
driver-class-name: org.h2.Driver
jpa:
hibernate:
ddl-auto: create
properties:
hibernate:
# show_sql: true
format_sql: true
logging.level:
org.hibernate.SQL: debug
org.hibernate.type: trace
0
spring:
datasource:
url: jdbc:h2:tcp://localhost/~/jpashop
username: sa
password:
driver-class-name: org.h2.Driver
jpa:
hibernate:
ddl-auto: create
properties:
hibernate:
# show_sql: true
format_sql: true
logging.level:
org.hibernate.SQL: debug
org.hibernate.type: trace
이렇게 입니다!
0
package jpabook.jpashop.service;
import jpabook.jpashop.domain.Member;
import jpabook.jpashop.repository.MemberRepository;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import static org.junit.Assert.*;
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class MemberServiceTest {
@Autowired MemberService memberService;
@Autowired MemberRepository memberRepository;
@Autowired EntityManager em;
@Test
@Rollback(false)
public void 회원가입() throws Exception{
// given
Member member = new Member();
member.setName("kim");
// when
Long saveId = memberService.join(member);
// then
em.flush();
assertEquals(member, memberRepository.findOne(saveId));
}
@Test
public void 중복_회원_예외() throws Exception{
// given
// when
// then
}
}
현재 코드입니다.