본문 바로가기
728x90
반응형

spring64

[SpringBoot] Reactive RESTful Web Service 구축 실습 spring.io 가이드를 참조하여 WebFlux 실습을 해보겠습니다. 개념은 이전 포스팅에서 대충 끄적인 걸로 대체하겠습니다. 목표 Spring Webflux 및 해당 서비스의 WebClient consumer로 RESTful 웹 서비스를 구축 환경 Spring Boot 2.4.2 (spring 5 이상) Maven IntelliJ openjdk 11 프로젝트 생성 우선 WebFlux 프로젝트를 생성합니다. 최초 생성 시의 pom.xml 내용입니다. 4.0.0 org.springframework.boot spring-boot-starter-parent 2.4.2 com.moonsiri reactive 0.0.1-SNAPSHOT reactive Reactive RESTful Web Service 11 o.. 2021. 2. 18.
[Spring] Reactive Programming (1) - Reactor 3, WebFlux Spring WebFlux The original web framework included in the Spring Framework, Spring Web MVC, was purpose-built for the Servlet API and Servlet containers. The reactive-stack web framework, Spring WebFlux, was added later in version 5.0. It is fully non-blocking, supports Reactive Streams back pressure, and runs on such servers as Netty, Undertow, and Servlet 3.1+ containers. 5.0 버전에 추가된 스프링 웹 플럭스.. 2021. 2. 18.
[SpringBoot] Maven Multi-Module Project 생성 multi-module 가이드를 참조하여 Spring Boot로 멀티 모듈 프로젝트를 생성하는 스터디를 해보겠습니다. 멀티 모듈 프로젝트? 멀티 모듈 프로젝트는 기존의 단일 프로젝트를 프로젝트 안의 모듈로서 가질 수 있는 구조를 제공합니다. 장단점 장점 재사용, 공유 할 수 있다 빌드를 쉽게 할 수 있다 변경으로 인한 영향 최소화가 가능하다 의존성을 최소화한다. 목표 재사용 가능한 라이브러리를 생성하여 해당 라이브러리를 사용하여 "Hello, World" 메시지를 리턴하는 api 애플리케이션 빌드 환경 Spring Boot 2.4.2 Maven IntelliJ openjdk 11 프로젝트 생성 우선 스프링 부트 프로젝트 생성해봅니다. 모듈 생성 그다음 모듈을 생성하겠습니다. 위와 같은 방법으로 "api".. 2021. 2. 18.
[SpringBoot] JWT 설명 및 생성, 검증 JWT JWT는 JSON Web Token의 줄임말입니다. JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed. JWTs can be signed using a secret (with the HMAC algorithm) or a public/private key pair using RSA or ECDSA. JWT는 웹 표준.. 2021. 1. 18.
[Spring] JSONArray를 사용하지 않고 Ajax로 배열 list 넘기기 ajax로 배열 데이터를 넘기는 방법을 알아보겠습니다. 구글링을 해보면 대부분의 포스트가 배열을 파싱 하는 방법으로 JSONArray와 JSONObject를 이용하고 있는데, 다른 방법을 알려드리겠습니다. 아래와 같은 데이터를 Controller로 넘기려고 합니다. const data = { "id": 10, "typeList": [ {"type":"A", "typeNm":"에이"}, {"type":"B", "typeNm":"비"} ] }; 해당 데이터를 json dataType로 보내면, 아래와 같은 오류가 발생합니다. Property referenced in indexed property path 'typeList[0][type]' is neither an array nor a List nor a M.. 2021. 1. 6.
[Spring] java/jsp에서 properties value 불러오기 아래와 같은 common.properties 파일이 존재할 때 java와 jsp에서 값을 불러오는 방법을 알아보겠습니다. system.domain=http://localhost:8080 hello.world=hello world!! 1. java Application.java에 properties 파일을 설정하면, @PropertySource({ "classpath:properties/common.properties" }) public class Application { ... } @Value 어노테이션을 사용하여 properties값을 불러올 수 있습니다. import org.springframework.beans.factory.annotation.Value; @Cotroller public class.. 2021. 1. 5.
[Spring] local cache key, value 조회 및 삭제 @Cacheable 어노테이션을 사용하여 생성한 로컬 캐시 (ehCache)를 조회하고 삭제하는 방법을 알아보겠습니다. import org.springframework.cache.CacheManager; @Resource private CacheManager cacheManager; 1. Key, Value 정보 조회 1. ehcache public ResponseEntity ehCacheValues() { List result = new ArrayList(); for (String cacheName : cacheManager.getCacheNames()) { EhCacheCache cache = (EhCacheCache) cacheManager.getCache(cacheName); Ehcache ehc.. 2020. 12. 4.
[Spring] java config로 hikari datasource, transaction aop 설정 pom.xml org.springframework.boot spring-boot-starter-jdbc org.mybatis.spring.boot mybatis-spring-boot-starter 2.1.3 org.apache.commons commons-dbcp2 mysql mysql-connector-java runtime application.yml spring: datasource: hikari: driver-class-name: com.mysql.cj.jdbc.Driver jdbc-url: "jdbc:mysql://localhost/moonsiri_db?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTim.. 2020. 11. 1.
[Spring] Chrome 양식 다시 제출 확인 ERR_CACHE_MISS 해결방법 Chrome에서 POST 요청으로 페이지 이동후 뒤로 가기를 하면 아래와 같은 확인 페이지를 제공하도록 되어있습니다. ​ ​ ​Spring security를 사용하면 headers cacheControl를 disabled 처리함으로써 해결합니다. @Configuration @EnableWebSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) { http // ... .headers(headers -> headers .cacheControl(cache -> cache.disable()) ); } } Cache Control.. 2020. 10. 31.
[Spring] Mockmvc에 ExceptionHandler 등록 Controller Test 를 위해 MockMvc 기반으로 Test를 할 때, @ControllerAdvice 로 지정한 Global Exception Handler가 Test에서 동작하지 않을 때가 있습니다. ​ Mockmvc를 생성할때 아래와 같이 setControllerAdvice()로 사용할 class를 지정해주어야 합니다. ​ Normally @ControllerAdvice are auto-detected as long as they're declared as Spring beans. However since the standalone setup does not load any Spring config, they need to be registered explicitly here instead.. 2020. 10. 31.
728x90
반응형