개발이 좋아서/Troubleshooting이 좋아서

    cors 에러 문제 - trim을 안했다..

    cors 에러 문제가 자꾸 나서 원인을 파악하려 했지만 찾기가 힘들었다.이미 하라는 것은 다했기 때문에 뭐가 문제인지 몰랐다. 하지만 원인은 너무도 쉬운 것이었다.원래 쉬운 것을 찾는게 더 어려운 것 같다.... app: cors: allowedOrigins: http://localhost:8080, http://localhost:8081, http://localhost:3000 이런식으로 허용해주고 있었는데 private List parseAllowedOrigins() { return Arrays.asList(allowedOrigins.split(","));}- 여기가 문제였다. 콤마하고 띄워쓰기가 있어서 제대로 적용이 되지 않았던 것이다...ㅠㅠㅠ private List parseAllo..

    빈 등록 안하고 싶을 때 - @Autowired(required = false)

    빈 등록이 필수가 아닌데 final로 빈을 등록하고 있었다!!그래서 @Autowired(required = false)를 주었다. 이후 null 체크를 하여 코드를 진행하였다.@Autowired(required = false)private SlackNotifier slackNotifier;if(slackNotifier != null) { // Slack으로 에러 알림 전송 slackNotifier.sendErrorNotification( "서버 에러 발생 (500 Internal Server Error)", e.getMessage() != null ? e.getMessage() : "알 수 없는 서버 에러가 발생했습니다.", e );}

    @WithCustomMockUser - 테스트 코드 작성 시 인증

    컨트롤러단에서 @AuthenticationPrincipal을 이용해 id값을 가져와 쓰고 있었다.테스트 코드를 작성하는데 id값을 어떻게 가져와야 할 지 몰랐다. 그래서 @WithCustomMockUser 어노테이션을 만들어 사용하였다.package com.swyp.libri.domain.annotation;import org.springframework.security.test.context.support.WithSecurityContext;import java.lang.annotation.Retention;import java.lang.annotation.RetentionPolicy;@Retention(RetentionPolicy.RUNTIME)@WithSecurityContext(factory = ..

    There were failing tests. See the report at: file:///C:/repository/ 프로젝트/build/reports/tests/test/index.html

    사이드 프로젝트를 하는 도중 Swagger와 restDocs를 같이 쓸 수 있다하여 우선 빌드를 했다.그런데 There were failing tests. See the report at: file:///C:/repository/ 프로젝트/build/reports/tests/test/index.html이런 에러가 뜨는 것이다.에러 경로를 따라가 파악해보니 테스트 코드는@ActiveProfiles("test")이것으로 테스트 환경에서 돌리는 것이었다. 그래서 application-test.yml에 jwt와 Oauth와 같은 설정 정보를 넣어줘서 apllication-local.yml 파일과 맞추어 줘야 한다는 것을 알았다.