해결된 질문
작성
·
856
0
yml 파일
spring: #띄어쓰기 없음
datasource: #띄어쓰기 2칸
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
defer-datasource-initialization: true
logging:
level:
org.hibernate.SQL: debug
# org.hibernate.type: trace
MemberController 파일
package jpaproject.jpashop.controller;
import jpaproject.jpashop.domain.Address;
import jpaproject.jpashop.domain.Member;
import jpaproject.jpashop.service.MemberService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import javax.validation.Valid;
@Controller
@RequiredArgsConstructor
public class MemberController {
private final MemberService memberService;
@GetMapping("/members/new")
public String createForm(Model model){
model.addAttribute("memberForm",new MemberForm());
return "members/createMemberForm";
}
@PostMapping("/members/new")
public String create(@Valid MemberForm memberForm){
Address address = new Address(memberForm.getCity(), memberForm.getStreet(), memberForm.getZipcode());
Member member = new Member();
member.setName(memberForm.getName());
member.setAddress(address);
memberService.join(member);
return "redirect:/";
}
}
콘솔창
h2 데이터베이스
도저히 원인을 모르겠네요 도와주세요
해결됐습니다!! 정말 감사합니다