전체 글
-
[25] Spring Data : Spring Data - JPA 연동Spring/Spring boot 2020. 7. 15. 08:53
[Spring Data JPA의 사용의 기본] 1. pom.xml file에 org.springframework.boot:spring-boot-starter-data-jpa 의존성을 추가해줍니다. ... ... org.springframework.boot spring-boot-starter-data-jpa ... ... 2. 본 Post에서 db는 docker를 통한 postgresql을 사용합니다. (postgresql 관련 포스트) docker를 통해 postgresql을 먼저 실행해주세요. postgresql을 사용하기 위한 의존성을 pom.xml에 추가해줍니다. ... ... org.postgresql postgresql ... ... application.properties file에 sprin..
-
[24] Spring Data : ORM, JPA, Spring-Data-JPA 개요Spring/Spring boot 2020. 7. 13. 15:53
[Object Relational Mapping] Object Relational Mapping (ORM)은 객체와 DB table을 mapping 할 때 발생하는 다음 표와 같은 개념적 불일치를 해결하기 위한 solution을 제공하는 framework입니다. 구분 Class RDB Data Type Object, primitive type, reference type... Integer, Char... 상속(Inheritance) 개념 있음 없음 Identity hash code, equals method() primary key [Java Persistence API] Java Persistence API는 ORM 구현체(Hibernate, Eclipse Link ...)를 사용할 수 있도록 제공되..
-
[23] Spring Data : PostgreSQL 설정하기Spring/Spring boot 2020. 7. 11. 09:05
[PostgreSQL 사용을 위한 설정] 우선 PostgreSQL driver 의존성을 추가해줍니다. pom.xml file의 dependencies tag 안에 다음의 의존성 관련 code를 추가해주세요. ... org.postgresql postgresql ... application.properties file에 spring.datasource.* property들을 추가해줍니다. spring.datasource.hikari.maximum-pool-size=2 spring.datasource.url=jdbc:postgresql://localhost:5432/springboot spring.datasource.username=dave spring.datasource.password=pass 접속하고자..
-
[22] Spring Data : MySQL 설정하기Spring/Spring boot 2020. 7. 9. 08:55
[DataBase Connection Pool - DBCP] Database를 사용하기 위해서는 먼저 Database와 연결(connection)할 수 있어야 합니다. 이 연결 작업은 cost가 높은 작업으로 Database에 작업이 필요할 때마다 connection을 진행하면 성능상 문제가 발생할 수 있습니다. 따라서 사용하기 전에 일정 수량의 DataBase Connection을 만들어 두고 필요로 할 때 할당하며 사용이 완료되면 connection을 pool로 반환하도록 합니다. 이렇게 DB connection을 담아두고 관리하는 pool을 DataBase Connection Pool (DBCP)라고 합니다. Spring boot에서 지원하는 DBCP의 종류는 다음과 같습니다. HikariCP (d..
-
[21] Spring Data : In-memory DatabaseSpring/Spring boot 2020. 7. 7. 08:56
[In-memory Database] data storage를 main memory(RAM)에 설치하여 운영되는 DBMS를 In-memory Database라고 합니다. In-momory Database의 장단점은 다음과 같습니다. 장점: data 접근 속도가 매우 빠름 단점: RAM이 휘발성이기 때문에 전원 차단시 RAM에 저장된 데이터는 모두 소실됨. 최근 비휘발성 RAM 기술의 도입으로 전원 차단에도 data의 영속성을 유지할 수 있게 되었음. Spring boot에서 지원하는 In-memory Database의 종류는 다음과 같습니다. H2 (recommended) HSQL Derby [Spring boot에서 In-memory Database 사용] 1.h2 database 사용을 위한 의존성 ..
-
[20] Spring Web MVC : CORSSpring/Spring boot 2020. 7. 4. 08:26
[CORS] Single-Origin Policy에 의해 하나의 origin에서 다른 origin의 resource에 대해 request 할 수 없습니다. 즉, http://localhost:8080에서 사용되고 있는 Rest API를 http://localhost:18080와 같이 다른 origin에서 AJAX 호출 등을 통해 request 할 수 없게 됩니다. Cross-Origin Resource Sharing (CORS)은 Single-Origin Policy를 우회하기 위해 web browser가 지원하는 기술입니다. CORS를 통해 서로 다른 origin 간에 resource를 sharing 할 수 있도록 해줍니다. [CORS 사용의 예] Spring에서 CORS 기능을 사용하기 위해 해야 하..
-
[19] Spring Web MVC : Spring HATEOASSpring/Spring boot 2020. 6. 30. 08:36
[HATEOAS] Hypermedia As The Engine Of Application State(HATEOAS)는 application의 상태(state)를 관리하기 위한 기술입니다. 이 기술은 기존 REST API의 단점을 보완한 것으로, client는 특정 resource에서 이동할 수 있는 다른 resource에 대한 link를 server로부터 전달받아 사용합니다. (client가 접근할 수 있는 resource에 대한 link를 미리 알아야 하는 이유는 무엇?) Spring HATEOAS는 Spring framework에서 HATEOAS를 구현하기 위해 제공되는 library입니다. HATEOAS에 의해 생성되는 response data에는 사용 가능한 자원인지 여부에 따라 접근 가능한 AP..
-
[18] Spring Web MVC : ExceptionHandlerSpring/Spring boot 2020. 6. 28. 09:19
[BasicErrorController] BasicErrorController는 spring boot에 기본적으로 등록되어 있는 error handler입니다. accept header에 따라 구분된 결과를 response 합니다. accept header에 "text/html"이 있는 경우(browser에서 reqeust 시) : html로 response 합니다. accept header에 "text/html"이 없는 경우(console에서 curl로 request 시) : json으로 response합니다. BasicErrorController class의 내용을 보면 다음과 같습니다. @ExceptionHandler 대신 @RequestMapping을 통한 기본 mapping이 error로 되어 ..