본문 바로가기

Spring Boot4

[spring] 스프링 부트에서 REST Client 이용하기 스프링 REST Client 스프링에서 제공 스프링 부트는 쉽게 사용할 수 있도록 자동설정 제공 주의 : RestTemplate / WebClient 자체를 빈으로 등록 X → RestTemplateBuilder / WebClient.Builder를 빈으로 등록 O 1. RestTemplate Blocking I/O 기반의 Synchronous API RestTemplateAutoConfiguration 프로젝트에 spring-web 모듈이 있다면 RestTemplateBuilder를 빈으로 등록 2. WebClient Non-Blocking I/O 기반의 Asynchronous API WebClientAutoConfiguration 프로젝트에 spring-webflux 모듈이 있다면 WebClient... 2020. 5. 23.
[spring] 스프링 부트에서 Spring Security 커스터마이징하기 Web Security 커스터마이징 - WebSecurityConfigurerAdapter를 상속하던 SpringBootWebSecurityConfiguration 대체 - 모든 HTTP요청에 인증을 요구하던 스프링 부트의 자동설정 해제 WebSecurityConfigurerAdapter를 implements하는 @Configuration class 생성 스프링 부트의 SpringBootWebSecurityConfiguration이 빈으로 등록되지 않게 된다. HttpSecurity 객체를 파라미터로 받는 configure 메소드 오버라이드 authroizeRequest() : http요청을 위한 웹 기반 보안을 설정하겠다는 의미 antMatchers() : ant pattern으로 URL지정 permi.. 2020. 5. 21.
[spring] 스프링 부트에서 Spring Security 사용하기 Spring Security 보안과 관련된 인증(Authentication) / 권한부여(Authorization) 기능 제공 Spring Security 실습할 view 준비하기 Thymeleaf로 view rendering을 할 것이므로, spring-boot-starter-thymeleaf 의존성 추가 컨트롤러 추가하여 "/hello" 및 "/my" GetMapping index / hello / my html 생성 테스트1 @WebMvcTest로 MockMvc 주입받기 hello / my에 get요청을 보내는 @Test 생성 (mockMvc.perform(get("/hello")) ResultActions의 andExpect(view().name("hello"))로 이름 확인! cf) 아무의미 없.. 2020. 5. 19.
[spring] Annotation 내 classpath의 기본경로 Spring Boot을 시작하면서 Configuration을 Injecting하는 과정을 배우고 있다. @Configuration을 conjuction으로 하는 @PropertySource( )에서, classpath의 기준 경로는 어디일까 궁금했다. package board.configuration; import javax.sql.DataSource; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.. 2019. 12. 14.