전체 글(34)
-
Spring boot 순환 참조 문제
1. 문제 상황 The dependencies of some of the beans in the application context form a cycle: ┌──->──┐ | your filename defined in file [yourfilenamePath/yourfile.class] └──> JwtProvider @Bean >> MemberDetailsSerivceImpl @Bean >> AuthenticationManager를 생성자 주입 JwtAuthenticationFilter.java @Bean >> AuthenticationManager를 생성자 주입 ** AuthenticationManager때문에 순환 참조 오류 발생 ** 해결하기 위해 한개만 빈 설정
2023.12.12 -
Spring boot OAuth 로그인(0)
0. 개요 Spring boot를 이용한 OAuth로그인 구현을 위한 Spring boot Security에 대한 기초 지식 OAuth 로그인은 회원가입을 하지 않고 타사의 사이트의 접근 권한을 얻고 그 권한을 이용하여 개발할 수 있도록 도와주는 프레임워크이다. 구글, 카카오, 네이버등과 같은 사이트에서 로그인을 하면 직접 구현한 사이트에서도 로그인 인증을 받을 수 있도록 되는 구조이다. 1. Spring boot Security 방식 1) Client의 요청 (HttpRequest) 2) Spring boot의 Security가 해당 url을 찾아서 SecurityFilterChain에게 알맞게 매핑해 줌 // 예시 1) WebSecurityConfig.java 3) 해당 사항을 처리할 Security..
2023.12.11 -
Spring boot OAuth 로그인(1)
0. 개요 Spring boot를 이용한 OAuth로그인 구현 해당 로그인은 회원가입을 하지 않고 타사의 사이트의 접근 권한을 얻고 그 권한을 이용하여 개발할 수 있도록 도와주는 프레임워크이다. 구글, 카카오, 네이버등과 같은 사이트에서 로그인을 하면 직접 구현한 사이트에서도 로그인 인증을 받을 수 있도록 되는 구조이다. 1. Spring boot 코드 짜기 전에 해야할 것 1. kakao Devloper 로그인 https://developers.kakao.com/console/app 카카오계정 accounts.kakao.com 2. 애플리케이션 추가하기 3. 애플리케이션 추가하기 4. REST API KEY 체크하기 5. 활성화 설정 OFF -> ON과 Redirect uri 설정하기 6. 동의항목 체..
2023.12.07 -
Spring boot 환경 변수 설정
0. 개요 application.yml 또는 application.properties에 민감한 정보를 넣어야할 때, 이를 안 보이게 설정하기 1. application.yml spring: jpa: show-sql: true properties: hibernate: format_sql: true defer-datasource-initialization: true datasource: url: jdbc:mysql://localhost:3306/menu username: ${your_username} password: ${your_password} driver-class-name: com.mysql.cj.jdbc.Driver h2: console: enabled: true jwt: secret_key: ${..
2023.12.05 -
Spring boot Test code(1)
0. Test code를 작성하는 이유? test code를 작성하지 않고 결과를 검증하는 시간을 줄여준다. 테스트 코드 작성을 통하여 기존에 검증 과정인 Spring boot application 실행 및 swagger 또는 Postman과 같은 검증 방법을 시행하지만 테스트 코드를 작성하면 해당 src/test/ 디렉터리에서 해당 코드를 실행하면 코드를 검증할 수 있어 시간 단축 및 코드 리뷰하기 편리하다. 1. Test code 작성 전 실제 데이터베이스를 Mysql을 사용하고 테스트 H2 데이터베이스를 사용합니다. 1) build.gradle dependencies { testImplementation 'org.springframework.boot:spring-boot-starter-test' t..
2023.12.04 -
Spring boot 중복된 Bean 에러
Spring boot에 빈으로 등록된 class는 한 개인데, 에러가 발생하는 경우 1. 에러 상황 nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'memberRepository' for bean class [클래스 경로] conflicts with existing, non-compatible bean definition of same name and class SecurityConfig 해당 에러는 파일의 이동 또는 삭제를 하면서 빈에 대한 기록이 아직 남아 있을 때, 생기는 오류입니다. 2. 에러 해결 방법 이전에 빌드된 클..
2023.11.30