Tag Archives: java

Spring @PostConstruct

스프링으로 개발하다 보면 객체가 생성될때 초기화 작업을 하고 싶을때가 있다. 이럴때 클래스의 생성자에 코드를 많이 넣는데 만약 value injection 된 값을 가지고 할경우에 두가지 방법이 있다. 첫번째로 생성자 부분에 @Value 어노테이션을 사용해 값을 주입하는 방법 두번째로 @PostContruct를 활용하는 방법 @PostContruct는 Injection이 끝난 후에 실행되기 때문에 가능하다.

Spring Config Server S3 Multi Load Config

# spring config에서 멀티 s3 config를 지원하는 기능은 spring-cloud-config v3.0.2에 contribute 되었습니다. spring config server를 사용하다 보면 common 적인 설정은 따로 모아서 관리하고 싶을때가 있다. a service – a-serivce-dev.yml – common-dev.yml b service – b-service-dev.yml – common-dev.yml 다른 서비스이지만 공통적인 설정 부분은 하나의 파일로 관리하고 싶을때. spring.cloud.config.name: a-service, common 요렇게 해주면 두개의 config 파일을 로딩이… Read More »

Spring Security Custom Request Parameter 사용하기

username / password 이외에 추가 파라미터(ex: OTP 코드)를 처리하기 위한 방법이다. 간단히 요약하면 addFilterBefore 필터에 Custom UsernamePasswordAuthenticationFilter 를 추가하여 Custom WebAuthenticationDetails 로 변경하여 넘겨주는 방식 위 코드는 일부를 발췌한 내용이라 보고 참고 정도만 하세요.