<spring>/기초 Spring Basic2023. 9. 26. 15:53[파편 조각 - Spring Web] Controller

Spring WEB DS -> Controller -> Service -> JPARepository ex) 유저 클래스에 @RestController Annotation 달기 @RestController public class UserRestController { }

<spring>/기초 Spring Basic2023. 9. 26. 15:48[파편 조각 - Spring Web] Service

Spring WEB DS -> Controller -> Service -> JPARepository ex) 유저 클래스에 @Service Annotation 달기 @Service public class UserService { } @RequiredArgsConstructor을 안달아주면 Repository를 DI하려고 할 때, `Variable 'userJPARepository' might not have been initialized` 이런 알림창이 겁나 떠대니 요 Annotation도 달아줘야 한다.

[파편 조각] Spring 기초 편
<spring>/기초 Spring Basic2023. 8. 31. 18:38[파편 조각] Spring 기초 편

(1) 스프링 프로젝트를 실행시키면 create 쿼리가 날아가는 이유 ;; Spring Project에서 Entity 클래스 파일(.java)을 만들고 해당 클래스에 @Entity 어노테이션을 붙여주면 Spring에서는 해당 클래스 코드를 테이블로 인식하고 application 설정 파일에 ddl-auto를 create로 설정해놓으면 매번 프로그램을 실행시킬 때마다 DB에 테이블을 생성하고 로그에 sql 쿼리가 찍히는 이유는 show-sql 설정이 true로 되어있기 때문이다

image