Spring&SpringBoot
-
[스프링부트/웹 애플리케이션 개발]엔티티 클래스 개발 -1Spring&SpringBoot 2023. 1. 4. 14:43
- 예제 > 쉽게 설명하기 위해 Getter, Setter 모두 열고 단순하게 설계 - 실무 > Getter는 열어두고 Setter는 꼭 필요한 경우에만 사용하는 것을 추천 >> 이론적으로 Getter, Setter 모두 제공하지 않고, 꼭 필요한 별도의 메서드를 제공하는 게 가장 이상적이다. 하지만 실무에서 엔티티의 데이터는 조회할 일이 너무 많으므로, Getter의 경우 모두 열어두는 것이 편리하다. Getter는 아무리 호출해도 호출하는 것 만으로 어떤 일이 발생하지는 않는다. 하지만 Setter는 문제가 다르다. Setter를 호출하면 데이터가 변한다. Setter를 막 열어두면 가까운 미래에 엔티티가 도대체 왜 변경되는지 추적하기 점점 힘들어진다. 그래서 엔티티를 변경할 때는 Setter 대신에..
-
[스프링부트/웹 애플리케이션 개발]기본 설계Spring&SpringBoot 2023. 1. 3. 17:52
요구사항 분석 기능 목록 - 회원 기능 > 회원 등록 > 회원 조회 - 상품 기능 > 상품 등록 > 상품 수정 > 상품 조회 - 주문 기능 > 상품 주문 > 주문 내역 조회 > 주문 취소 - 기타 요구사항 > 상품은 재고 관리가 필요하다. > 상품의 종류는 도서, 음반, 영화가 있다. > 상품을 카테고리로 구분할 수 있다. > 상품 주문 시 배송 정보를 입력할 수 있다. 도메인 모델과 테이블 설계 - 다대다 관계 > 엔티티(주문상품)를 추가해 일대다, 다대일 관계로 풀어낸다 회원 엔티티 분석 - 회원 : 이름과 임베디드 타입(내장값 타입)인 주소, 주문 리스트를 갖는다 회원 테이블 분석 - item > single table 전략, 테이블 하나에 넣고 DTYPE으로 구분 > table 하나에 모든 정보가..
-
[스프링부트/웹 애플리케이션 개발]H2 데이터베이스 설치, JPA와 DB 설정, 동작확인Spring&SpringBoot 2023. 1. 3. 16:53
- 저번에 이미 설치 완료 인프런 스프링 입문 08 / 스프링 DB 접근, H2, JDBC 스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술 스프링 DB 접근 기술 H2 데이터베이스 설치 - https://www.h2database.com/html/download-archive.html - 1.4.200 버전 platfrom-dindependent 다운로드 - 압축 gitofjy.tistory.com package jpabook.jpashop; import lombok.Getter; import lombok.Setter; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.per..
-
[스프링부트/웹 애플리케이션 개발]devtools setting, spring-boot-devtools 실행 안 될 때Spring&SpringBoot 2023. 1. 2. 17:14
build.gradle > 의존성 추가 dependencies { implementation 'org.springframework.boot:spring-boot-devtools' } 이게 끝인데 run해도 실행이 계속 안 됐다. 구글에 나온 것처럼 preferenc > compiler와 advanced setting을 해도 실행이 안 됨 https://www.inflearn.com/questions/188597/spring-boot-devtools%EA%B0%80-%EC%9E%91%EB%8F%99%EC%9D%84-%EC%95%88%ED%95%A9%EB%8B%88%EB%8B%A4-%E3%85%9C 이 글을 보고 나서 프로젝트를 닫기 > File > Open > 해당 프로젝트의 build.gradle 선택 ..
-
[스프링부트/웹 애플리케이션 개발]view 환경 설정, thymeleaf 템플릿 엔진Spring&SpringBoot 2023. 1. 2. 16:32
thymeleaf 템플릿 엔진 1. HelloController package jpabook.jpashop; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; @Controller public class HelloController { @GetMapping("hello") public String hello(Model model) { model.addAttribute("data", "Hello!"); return "hello"; // templates > hello.html 이동 } } - 스프링..
-
[스프링부트/웹 애플리케이션 개발]라이브러리Spring&SpringBoot 2023. 1. 2. 16:02
스프링 부트 라이브러리 spring-boot-starter-web > spring-boot-starter-tomcat: 톰캣 (웹서버) > spring-webmvc: 스프링 웹 MVC spring-boot-starter-thymeleaf : 타임리프 템플릿 엔진(View) spring-boot-starter-data-jpa > spring-boot-starter-aop > spring-boot-starter-jdbc > HikariCP 커넥션 풀 (부트 2.0 기본) > hibernate + JPA: 하이버네이트 + JPA > spring-data-jpa: 스프링 데이터 JPA spring-boot-starter(공통): 스프링 부트 + 스프링 코어 + 로깅 > spring-boot > spring-co..
-
[스프링부트/웹 애플리케이션 개발]스프링부트스타터 프로젝트 생성, 스프링부트버전확인, lombokSpring&SpringBoot 2023. 1. 2. 15:43
1. 프로젝트 생성 스프링 부트 스타터(https://start.spring.io/) - dependencies > spring web > thymeleaf > spring data JPA > H2 Database > Lombok > Validation 2. 스프링부트 버전 확인 - build.gradle 에서 확인 가능 3. run > 오류 해결 Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2023-01-02 14:53:06.504 ERROR 21048 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :..