728x90 반응형 전체 글198 [Spring] Mockmvc에 ExceptionHandler 등록 Controller Test 를 위해 MockMvc 기반으로 Test를 할 때, @ControllerAdvice 로 지정한 Global Exception Handler가 Test에서 동작하지 않을 때가 있습니다. Mockmvc를 생성할때 아래와 같이 setControllerAdvice()로 사용할 class를 지정해주어야 합니다. Normally @ControllerAdvice are auto-detected as long as they're declared as Spring beans. However since the standalone setup does not load any Spring config, they need to be registered explicitly here instead.. 2020. 10. 31. [Spring Batch4] 배치 Test를 위한 Configuration - Spring Batch Test 공식 문서 (한국어 번역)공식 문서에 나와있는 batch job의 end to end 테스트 예제는 다음과 같습니다.@SpringBatchTest@RunWith(SpringRunner.class) // 스프링 JUnit 기능을 사용하겠다는 표시@ContextConfiguration(classes = SimpleJobConfiguration.class) // ApplicationContext에 설정할 리소스 명시public class SimpleJobTest { @Autowired private JobLauncherTestUtils jobLauncherTestUtils; @Test public void simple_job_테스트() throw.. 2020. 10. 31. [JAVA] AWS S3 Https 연결이 비공개로 설정되어 있지 않습니다. (Your connection is not private) 해결방안 Https 연결 사용 시 서버 인증서가 필요합니다. 서버 인증서는 CA에서 서명한 x.509 v3 데이터 구조입니다.서버 인증서에는 서버 이름, 유효 기간, 퍼블릭 키 및 기타 데이터가 포함됩니다.브라우저가 웹 서버에 액세스하는 경우 모든 데이터 필드가 유효해야 합니다.인증서가 만료되었거나 아래와 같이 인증서가 도메인에 대해 유효하지 않은 경우 ACM(AWS Certificate Manager) 인증서 오류 메시지가 표시됩니다. 서버의 보안 인증서가 *.s3.ap-northeast-2.amazonaws.com 에 대해 제공을 하는데, wildcard name (*)을 사용하면 하나의 하위 도메인과만 일치하기 때문에 https://moonsiri.s3.ap-northeast-2.amazonaws.c.. 2020. 10. 31. [Spring Security5] SecurityFilterChain, Filter 이중 호출 해결 (Filter disabled) Multiple HttpSecurity 구성에서 서비스를 이동할 때, 각 서비스에서 사용하는 권한으로 변경하는 필터 AuthorityChangeFilter를 등록하려고 합니다.<p id="SE-cd093979-c8b7-433d-a3ce-f7414916109f" dat.. 2020. 10. 31. [Spring Security5] Multiple HttpSecurity, Multiple Login, accessDenied 설정 한 프로젝트에 여러 개 서비스가 있을 경우, 로그인 화면이 두 개 이상인 경우 다음과 같이 구성합니다.MultipleSecurityConfiguration.java (<a href="https://docs.spring.io/spring-security/site/docs/4.1.5... 2020. 10. 31. [Java8] 중복 데이터 제거를 위한 Stream distinct 중복 데이터를 제거하기 위해 Stream distinct를 사용합니다. 동일한 객체의 판단하는 기준은 Object.equals(Object)의 결과 값이다. String 객체의 경우 equals()가 이미 구현되어 있습니다. - Stream.distinct() : Returns a stream consisting of the distinct elements (according to Object.equals(Object)) of this stream. List strings = Arrays.asList("hello", "world", "hello", "java", "hello"); strings.stream().distinct().forEach(System.out::println); // "hello".. 2020. 10. 31. [SpringBoot] Jackson JsonAlias 설정 및 x-www-form-urlencoded 문제 해결 JsonAlias를 사용하기위해 pom.xml에 Jackson lib를 추가합니다. org.springframework.boot spring-boot-starter-web com.fasterxml.jackson.core jackson-databind com.fasterxml.jackson.core jackson-annotations 2.9.9 com.fasterxml.jackson.core jackson-databind 2.9.9 com.fasterxml.jackson.core jackson-core 2.9.9 @JsonAlias 사용법 @Data public class UserVO { @JsonAlias(value = {"name", "userNm", "userName"} private String n.. 2020. 10. 31. [java] StringBuffer getChars (Chars to String) https://www.tutorialspoint.com/java/lang/stringbuffer_getchars.htm Java.lang.StringBuffer.getChars() Method - Tutorialspoint Java.lang.StringBuffer.getChars() Method Description The java.lang.StringBuffer.getChars() method copy the characters from this sequence into the destination character array dst. The first character to be copied is at index srcBegin. The last character to www.tutorialspoin.. 2020. 10. 31. [spring] @ResponseBody Annotation vs ResponseEntity @ResponseBody annotation을 사용하면 스프링이 반환 객체를 http response body로 변환합니다. ResponseEntity는 @ResponseBody annotation과 유사하게 작동합니다. 그러나 ResponseEntity 객체를 생성할 때 response header를 http response에 추가할 수도 있습니다. responseEntity를 반환 객체로 사용하는 경우 @ResponseBody annotation을 사용할 필요가 없습니다. 예제) @ResponseBody annotation 사용 @ResponseBody @RequestMapping("/getData") public ResJsonVO getData(DataVO param) { try { return t.. 2020. 10. 31. [spring] @Valid를 이용한 validation 체크와 custom annotation으로 validation 1. Valid annotation을 이용한 validation 체크 우선, VO 클래스의 필드에 Validation을 체크하도록 annotation을 설정합니다. 예) @NotEmpty, @Length 등 @Data @EqualsAndHashCode(callSuper = false) public class SiriVO extends PagingCommonVO { private long siriId; @NotEmpty(message = "제목을 입력해주세요.") @Length(min = 0, max = 100, message = "The maximum length of the title value is 100. ") private String title; @CodeValid(message = "사용여부를.. 2020. 10. 31. 이전 1 ··· 13 14 15 16 17 18 19 20 다음 728x90 반응형