분류 전체보기 171

lombok (롬복) 설치하기.

롬복을 설치해보자. https://projectlombok.org/ 에서 lombok.jar 다운로드 예전에는 java가 path에 잡혀있어서 더블클릭하면 바로 실행. 안잡혀 있다면 CMD 를 실행 한 뒤, java -jar lombok.jar 명령어 입력. (당연히 lombok.jar 다운받은 디렉토리 이동 후 입력) Specify location 선택 후 eclipse or STS 실행 파일 선택 (eclipse.exe or sts.exe) Install / Update 로 설치 eclipse or STS 재시작

spring-project 2020.01.05

spring security 로그인 username 가져오기

첫번째 방법은 SecurityContextHolder를 사용하는 방법 Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); String username = authentication.getName(); logger.debug("current username : {}", username); 두번째 방법은 Method 선언에서 Principal 이나 Authentication 에 자동으로 할당 되는 값을 사용하는 방법 @RequestMapping(value = "/list") public String list(Principal principal, ...) { ... } @RequestMapping(valu..

spring-project 2020.01.03

Spring MVC Request 객체는 매번 새로 생성 됨.

스프링 MVC Request 요청이 오면 매번 새로운 객체가 생성 됨. Request 를 2번 요청하여 각각의 객체의 hash값을 보면 다른 걸 확인 할 수 있다. toString() 으로 객체의 hash 값을 보면 다르다. @RequestMapping(value = "/register", method = RequestMethod.POST) public String register(Locale locale, Model model, @ModelAttribute TestRegisterRequest testRegisterRequest) { logger.debug(informationRegisterRequest.toString()); return "redirect:/test/list"; DEBUG 18048 -..

spring-project 2020.01.02

Redis 처음 사용하기

[Homepage] https://redis.io/ [Redis란] open source (BSD licensed) in-memory data structure store (데이터베이스, cache, message broker 처럼 사용), NoSQL 데이터베이스, key-value 저장소라도 함 strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes with radius queries and streams 데이터 구조 지원 replication, Lua scripting, LRU eviction, transactions and different levels of on-dis..

redis 2019.10.13

Spring Boot 에서 JSP 사용하기 위한 라이브러리 추가

maven (pom.xml) org.apache.tomcat.embed tomcat-embed-jasper javax.servlet jstl gradle (build.gradle) #jsp spring.mvc.view.prefix=/WEB-INF/jsp/ spring.mvc.view.suffix=.jsp application.properties 에 다음과 같은 설정 추가 implementation 'org.apache.tomcat.embed:tomcat-embed-jasper' implementation 'javax.servlet:jstl:1.2' /main/webapp/WEB-INF/jsp/ 와 같이 디렉토리 만들고 jsp 파일 생성

spring-project 2019.09.13

Spring Boot 최초 실행 시 'Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. '

Spring Boot 초기 프로젝트를 Initializr를 통해서 생성 한 뒤 최초 실행 할 경우 다음과 같은 오류가 발생하면서 정상적으로 실행이 되지 않을 경우. *************************** APPLICATION FAILED TO START *************************** Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class Action: Consider the following: If you wan..

spring-project 2019.09.10

Spring Security를 이용한 Basic Authentication

Spring Security를 이용한 REST API Basic Authentication Basic Authentication이란? REST API 인증을 할 때, username, password로 인증을 하는 방법을 말한다.username, password를 입력하면 Client에서 username + password를 base64 인코딩을 이용하여 매 request 마다 서버에 전달하면서버에서는 이를 가지고 사용자인지 아닌지 판단 한다. base64 인코딩을 사용하기 때문에 인코딩 된 문자열이 노출이 되면 쉽게 username, password를알수 있다. SpringSecurity를 이용한 구현package com.quickguide.backend.config; import com.quickgu..

spring-project 2019.03.01

REST API 인증 방법

REST API 인증 방법 인증(Authentication) 과 인가(Authorization)란? 1. 인증(Authentication) - 사용자인지 아닌지를 확인. 주로 아이디/패스워드 인증이 많이 사용되나 생체인식 등의 인증도 사용. 2. 인가(Authorization) - 사용자가 권한이 있는지 없는지 확인하여 해당 행위를 제한하거나 가능하게 하게 함. REST API 인증 방법. 1. HTTP Basic Authentication- 사용자 이름과 암호 Base 64 인코딩을 하여 서버로 전송.- 요청 할 때 마다 사용자 이름과 암호를 전송해야 한다.- Man-in-the-middle attack.에 취약하다. 2. Cookies and Session- 세션은 키를 사용자 아이디에 매핑합니다.-..

spring-project 2019.03.01