분류 전체보기 171

Spring Security Custom UserDetailsService 구현하기

Spring Security Custom UserDetailsService(DB) 구현하기 이전에는 다음과 같이 USER를 메모리에 저장해놓고 Spring Security의 테스트를 하였다. @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { // add our Users for in memory authentication auth.inMemoryAuthentication().withUser("user").password("password").roles("USER"); } 하지만 실제로는 이렇게 사용하지 못하고 대부분 DB 등의 저장소에 사용자의 정보를 저장해놓고 사용해야 한다. 여기서는 DB에 저..

spring-project 2019.02.24

Spring Boot에 Spring Security 적용하기 (Spring Security Java Config)

Spring Boot에 Spring Security 적용하기 (Spring Security Java Config) Spring Boot에 Spring Security를 적용하기 위해서 할 일은 Spring Security Library를 추가(라이브러리를 classpath에 추가) 하기만 하면 된다. 초기 프로젝트 생성 시에 다음과 같이 라이브러리를 추가해주었다. dependencies { .... implementation 'org.springframework.boot:spring-boot-starter-security' .... } Spring Security가 적용되면 기본 설정이 적용되어 모든 HTTP endpoints의 접근에 인증을 해야 한다. 기본적인 설정으로는 사용할 수 없기 때문에 설정을..

spring-project 2019.02.23

Spring Boot Hello World 출력하기

Spring Boot Hello World 출력하기 package com.quickguide.backend.hello.controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloWorldController { @RequestMapping("/") public String hello() { return "Hello World!!"; } } 스프링 시큐리티가 적용되어 있으므로 기동시 나오는 로그인을 하면 hello world!! 가 출력된다.

spring-project 2019.02.23

Spring Boot 프로젝트 기동하기 (초기 프로젝트를 IntelliJ에서 Open 한 뒤에 실행하기)

Spring Boot 프로젝트 기동하기 (초기 프로젝트를 IntelliJ에서 Open 한 뒤에 실행하기) 여기까지 작업 내용 첨부파일 - quickguide 계정 및 DB를 생성해야 함. Gradle의 bootRun Task로 기동을 해본다. 스프링 부트를 Gradle로 실행을 할 때 서버가 기동이 되지 않는다. 다음과 같이 명확하게 왜 기동이 안되는지 콘솔에 로그가 출력된다.***************************APPLICATION FAILED TO START*************************** Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasour..

spring-project 2019.02.23

Spring boot 프로젝트 초기 생성

Spring boot 프로젝트 초기 생성 1. SPRING INITIALIZR 에 접속하여 스프링 부트 초기 프로젝트를 생성한다. Spring Boot 2.1.3 + Gradle 선택Group 입력Artifact 입력Dependencies 입력 WebSecurityJPADevToolsMySQLLombokAspectsRedisKafkaMailElasticsearch 입력 후 Generate Project 버튼을 클릭하여 스프링 부트 프로젝트를 다운 받는다.(backend.zip 다운로드) [Spring INITIALIZR 설정 입력 화면] 각각의 라이브러리 관련 Getting Started 가이드 문서 GuidesThe following guides illustrates how to use certain ..

spring-project 2019.02.23

Docker auto start container on reboot

Docker auto start container on reboot 도커로 elasticsearch를 띄웠는데 컴퓨터를 재부팅 할 때 마다 다시 실행시켜줘야 하는 귀찮은 일이 생겼다. 컴퓨터 재부팅 시에 자동으로 컨테이너 실행을 위해서는 다음과 같이 하면 된다. docker 명령어로 elasticsearch 실행한다고 하면 docker run 명령어 중간에 --restart 옵션을 넣어주면 된다. docker run -restart always -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.4.3 - always옵션 이외에도 다른 옵션도 있으니 다음 사이트에서 찾..

now 2019.02.21