본문 바로가기

분류 전체보기77

[gradle] gradle 5부터 lombok의 설정을 신경써야 한다 오류 상황 //build.gradle dependencies { //Util implementation "org.projectlombok:lombok" } //오류 메세지 error: variable courseRepository not initialized in the default constructor - build.gradle에 implementation으로 lombok 의존성을 추가하고, Intellij 프로젝트에서도 enable annotation processing 옵션을 활성화한 상태 - 그런데 @RequiredArgsConstructor를 선언한 Service에서 default constructor를 사용하게 됨 - 결국 생성자에 필요한 인자인 courseRepository를 주입받지 못하.. 2020. 6. 14.
[spring] 스프링 부트에서 @WebMvcTest 사용하며 RestTemplate 주입받기 오류가 발생한 코드 @RestController @RequestMapping("/api/v1") public class ForecastController { private final ForecastYmlRead forecastYmlRead; private final RestTemplate restTemplate; private final ForecastService forecastService; public ForecastController(RestTemplateBuilder restTemplateBuilder, ForecastService forecastService, ForecastYmlRead forecastYmlRead){ this.restTemplate = restTemplateBuilder.b.. 2020. 6. 11.
[java] 익명 클래스와 람다식 익명 클래스 - 추상클래스를 상속하거나 인터페이스를 구현한, 이름없는 클래스 - 재사용이 필요없는 인스턴스를 생성할 때 사용 사용법 CustomInterface inf = new CustomInteface(){ //인터페이스의 추상 메소드 구현 }; - 상속(구현)하는 추상클래스(인터페이스)의 모든 추상메소드를 구현해야 한다. - 익명 인스턴스에서만 사용할 수 있는 필드와 메소드 선언 가능 - 익명 클래스도 컴파일 성공 시, 클래스파일이 생성된다. 예시 //구현 대상 public interface Person { public void foo(); public void bar(); } public class SampleApplication { public static void main(String[] ar.. 2020. 6. 10.
[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.