Yeon's Frame
  • Intro
  • Project
    • 미소웨더
      • 기획 - 아이디어 및 유스케이스 정리
      • DB 설계 - JPA 활용 중심
  • Study
    • Spring
      • Spring Feature
      • N+1
      • OSIV
      • @Valid
      • Spring Boot Feature
      • Spring 5 Feature
      • JPA vs MyBatis
      • Filter, Interceptor
      • Persistence Context
      • @Transactional
      • @Controlleradvice, @ExceptionHandler
      • Spring Security
      • Dispatcher Servlet
      • @EnableWebMvc
      • Stereo Type
      • AOP
      • JPA Repository
    • Infrastructure
      • Git
      • DNS
      • JWT
      • DevOps
      • Docker
      • Jenkins
      • Cloud Computing
      • MSA
    • Clean Code
      • 깨끗한 코드
      • 의미있는 이름
      • 함수
      • 주석
      • 형식 맞추기
      • 객체와 자료구조
      • 오류 처리
      • 경계
      • 단위테스트
      • 클래스
      • 시스템
  • Basic
    • Java
      • OOP
      • OOL Features
      • Class & Objects
      • Instance & Heap Memory
      • Constructor
      • Reference Type Uses
      • Access Modifier & Hiding
      • This
      • Collaboration
      • Static
      • Inheritance
      • Polimorphism & Casting
      • Abstract Class
      • Interface
      • Object Class
    • Java Coding
      • JVM
      • String, StringBuffer, StringBuilder
      • SOF
      • Blockcing/NonBlocking
      • Enum
      • Static
      • Thread
      • hashCode() | equals()
      • JDK8
      • Stream
      • Optional
      • Lambda & Closure
      • Exception
      • Garbage Collecter
      • Collection
      • Call by Value & Call by Reference
      • Generic
    • Java_Advance
      • Inner Class
      • Lambda Expression
      • Functional Interface
      • OOP vs Lambda Expression
      • Stream
      • Reduce()
      • Exception Handling
      • Custom Exception
      • Error Log
      • IO Stream
      • IO Stream - Serialization
      • File Class
      • Decorator Pattern
      • Thread
    • Data Structure
      • Intro
      • Generic(1)
      • Generic(2) T extends
      • Generic(3) Method
      • Collection Frameworks
      • List
      • Iterator
      • Set
      • Comparable & Comparator
      • Map
  • Practice
    • Algorithm
      • Strategy
        • Primitive, Reference, Generic
        • Number Data Types
        • For-Each
        • Array, Queue, ArrayDeque
        • Array vs ArrayList
Powered by GitBook
On this page
  • Spring 5 특징
  • 핵심 프레임워크 개정
  • 핵심 컨테이너 업데이트
  • 코틀린을 사용한 함수형 프로그래밍
  • 리액티브 프로그래밍 모델
  • 향상된 테스트
  • 라이브러리 갱신
  • 갱신된 지원 패키지
  • 지원 중단 패키
  • 참고
  1. Study
  2. Spring

Spring 5 Feature

Spring Framework 5 특징에 대해서 살펴보자

PreviousSpring Boot FeatureNextJPA vs MyBatis

Last updated 2 years ago

Spring 5 특징

  • JDK 기준 업데이트

  • 핵심 프레임 워크 개정

  • 핵심 컨테이너 업데이트

  • Kotlin을 사용한 함수형 프로그래밍

  • 반응 형 프로그래밍 모델

  • 테스트 개선

  • 라이브러리 갱신

핵심 프레임워크 개정

Spring Framework 5.0 에서는 Java 8에 도입 된 새로운 기능을 활용하도록 수정되었다.

  • Java 8 리플렉션 향상을 기반으로 Spring Framework 5.0의 메서드 매개 변수에 효율적으로 액세스 가능

  • @Nullable 및 @NotNull 주석은 명시 적으로 nullable 인수를 표시하고 값을 반환

  • 표준 Commons Logging 대신 spring-jcl이라는 Commons Logging 브리지 모듈과 함께 기본 제공

핵심 컨테이너 업데이트

  • 클래스 경로 스캔의 대안으로 후보 컴포넌트 인덱스를 지원한다. 이 지원은 클래스 경로 스캐너에서 후보 구성 요소 식별 단계를 바로 가기 위해 추가 되었다.

  • 클래스 경로를 스캔하지 않고 색인에서 항목을 읽는 것은 클래스가 200 개 미만인 소규모 프로젝트의 경우 큰 차이가 없다. 그러나 대규모 프로젝트에는 상당한 영향이 있을 수 있다. 구성 요소 인덱스를 로드하는 것은 저렴하기 때문에 클래스 수가 증가함에 따라 일정하게 유지된다.

  • 컴포넌트 인덱스 스캔 기능은 의존성을 추가하면 바로 사용할 수 있다.

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-indexer</artifactId>
            <version>5.0.3.RELEASE</version>
            <optional>true</optional>
        </dependency>
    </dependencies>

코틀린을 사용한 함수형 프로그래밍

Spring Framework 5.0은 JetBrains Kotlin 언어를 지원한다. Kotlin은 함수형 프로그래밍 스타일을 지원하는 객체 지향 언어이다.

@Bean
fun apiRouter() = router {
    (accept(APPLICATION_JSON) and "/api").nest {
        "/book".nest {
            GET("/", bookHandler::findAll)
            GET("/{id}", bookHandler::findOne)
        }
        "/video".nest {
            GET("/", videoHandler::findAll)
            GET("/{genre}", videoHandler::findByGenre)
        }
    }
}

리액티브 프로그래밍 모델

  • 반응형 스택 웹 프레임워크를 지원한다.

  • 반응형이며 논 블록킹으로 동작하여 소수의 스레드로 확장할 수 있는 리벤트 루프 스타일 처리에 적합하다.

  • java 8 lambda를 사용한 함수형 스타일 라우팅 및 처리가 가능하다.

  • @Controller와 Spring MVC의 Annotation 기반으로 구현 가능하다.

  • Reactive Streams API는 공식적으로 Java 9의 일부이므로, Java 8에서는 의존성을 추가해야 한다.

// Option1. @Controller 기반
@RestController
public class BookController {
 
    @GetMapping("/book")
    Flux list() {
        return this.repository.findAll();
    }
 
    @GetMapping("/book/{id}")
    Mono findById(@PathVariable String id) {
        return this.repository.findOne(id);
    }
}

// Option2. Router/Handler 기반

RouterFunction personRoute =
    route(
        GET("/books/{id}").and(accept(APPLICATION_JSON)), handler::getBook)
        .andRoute(GET("/books").and(accept(APPLICATION_JSON)), handler::listBooks);

향상된 테스트

  • Junit 5 Jupiter 완벽지원

  • 리액티브 모델의 경우 Spring Webflux에 대한 테스트를 지원하기 위해 WebTestClient를 사용할 수 있다.

  • Spring TestContext Framework에서 병렬 테스트 실행을 지원한다.

// WebClient 사용한 테스트 케이스 
Mono book = WebClient.create("<http://localhost:8080>")
      .get()
      .url("/books/{id}", 1234)
      .accept(APPLICATION_JSON)
      .exchange(request)
      .then(response -> response.bodyToMono(Book.class));

라이브러리 갱신

갱신된 지원 패키지

  • Jackson 2.6 이상

  • EhCache 2.10+ / 3.0 GA

  • 최대 절전 모드 5.0 이상

  • JDBC 4.0 이상

  • XmlUnit 2.x 이상

  • OkHttp 3.x 이상

  • Netty 4.1 이상

지원 중단 패키

  • beans.factory.access

  • jdbc.support.nativejdbc

  • web.view.tiles2M

  • orm.hibernate3 및 orm.hibernate4

  • JasperReports

  • XMLBeans

  • JDO

  • Guava

참고

https://dzone.com/articles/whats-new-in-spring-framework-5
https://www.journaldev.com/20714/spring-5
https://shuiky.tistory.com/entry/springframework-5-새로운-기능
https://blog.algaworks.com/spring-framework-5/