본문 바로가기

Java8

[에러모음] java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String 에러 상황 자바에서 여러 로그인 API를 이용해 로그인을 구현하고자 할 때 구글, 페이스북, 네이버는 다 잘 됐는데 카카오 UserInfo.java만 이런 에러가 떴다. public class KakaoUserInfo implements OAuth2UserInfo { private Map attributes;// getAttributes() private Map attributesAccount;// getAttributes().get("kakao_account") private Map attributesProfile;// attributesAccount.get("profile") public KakaoUserInfo(Map attributes) { this.attributes = attributes; t.. 2023. 3. 23.
[에러모음] com.auth0.jwt.exceptions.AlgorithmMismatchException: The provided Algorithm doesn't match the one defined in the JWT's Header 에러 설명 자바 프로젝트에서 로그인을 구현하기 위해 시큐리티 필터를 통해 JWT 토큰을 생성하고 확인하는 과정에서 생긴 에러 JwtAuthenticationFilter.java @RequiredArgsConstructor public class JwtAuthenticationFilter extends UsernamePasswordAuthenticationFilter { private final AuthenticationManager authenticationManager; // /login 요청을 하면 사용자 정보를 인증하기 위해 실행되는 함수 @Override public Authentication attemptAuthentication(HttpServletRequest request, HttpServ.. 2023. 3. 21.
[에러모음] Failed to evaluate expression 'hasRole('ROLE_USER') or hasRole('ROLE_MANAGER') or hasROLE('ROLE_ADMIN')' 에러 설명 자바 프로젝트에서 SecurityConfig.java를 통해 시큐리티 필터를 거쳐 웹 페이지 접근할 때 생긴 에러 @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true) @RequiredArgsConstructor public class SecurityConfig extends WebSecurityConfigurerAdapter{ @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable(); http.sessionManagement().sessionC.. 2023. 3. 19.
[에러모음] The dependencies of some of the beans in the application context form a cycle 에러 설명 자바 프로젝트 중 2개의 클래스가 서로를 참조하는 형태를 가질 때 생기는 에러 SecurityConfig.java @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true) @RequiredArgsConstructor public class SecurityConfig extends WebSecurityConfigurerAdapter{ @Autowired private PrincipalOauth2UserService principalOauth2UserService; // 문제되는 부분 @Bean public BCryptPasswordEncoder encodePwd.. 2023. 3. 18.
네이버 로그인 API Goal 1. 네이버 로그인 API 사용하기 네이버 로그인 API 1. https://developers.naver.com/apps/#/register 네이버 로그인 하기 2. 애플리케이션 등록 (API 이용신청) > 칸 채워넣기 > 등록하기 3. 애플리케이션 정보 Client ID와 Client Secret을 application.properties에 채워넣기 4. 자바 프로젝트 application.properties에 네이버 로그인 관련 security 설정하기 # NAVER SECURITY spring.security.oauth2.client.registration.naver.client-id=클라이언트ID입력 spring.security.oauth2.client.registration.naver.. 2023. 3. 17.
Facebook 로그인 API Goal 1. 페이스북 로그인 API 사용하기 페이스북 로그인 API 1. https://developers.facebook.com/apps/ 에서 페이스북에 로그인하기 2. 페이스북 로그인 API 사용하기 > My Apps 3. 앱 만들기 4. 앱 타입 선택하기 > 다음 5. 앱 이름 쓰기 > 앱 만들기 6. Facebook 로그인 설정하기 > 웹 > 사이트 URL에 http://localhost:8080 쓰기 > 다음 > 다음 > 다음 > 돌아가기 7. 설정 > 기본 설정 > 앱 ID와 시크릿 코드 확인 8. App ID와 secret을 application.properties에 복붙하기 ## application.properties에 페이스북 로그인 API 설정 # SECURITY spring.se.. 2023. 3. 16.
구글 로그인 API Goal 1. 구글 로그인 API 사용하기 구글 API 1. Google API Console https://console.cloud.google.com/apis/dashboard?project=able-math-371003&organizationId=0 2. 프로젝트 새로 만들기 3. 새로 만든 프로젝트 선택 4. OAuth 동의 화면 > “외부” 선택 > 만들기 5. 앱 이름과 유저 이메일 설정하기 > 저장 6. 사용자 인증 정보 > 사용자 인증 정보 만들기 > OAuth 클라이언트 ID > 만들기 7. OAuth 클라이언트 ID와 secret 복사해서 자바 프로젝트 application.properties에 쓰기. 이 정보는 개발자만 알고 있어야하는 정보입니다. 깃허브나 밖으로 노출되지 않도록 주의.. 2023. 3. 15.
Java, JIT Compiler, JVM Goal 1. 자바의 컴파일 과정 이해하기 2. JVM의 역할 설명하기 Q. 자바 소스코드가 컴파일 되는 과정을 설명해 보시오. A. 개발자가 자바 소스코드를 작성한다 (*.java) 자바 컴파일러가 소스코드 파일을 바이트코드로 컴파일 한다 (*.class) 바이트코드를 JVM (Java Virtual Machine)의 클래스 로더에 전달한다 클래스 로더는 동적로딩을 통해 필요한 클래스들을 로딩 및 링크하여 JVM 메모리에 올린다 실행 엔진(인터프리터 또는 JIT 컴파일러)은 JVM 메모리에 올라온 바이트 코드들을 명령어 단위로 하나씩 가져와 실행한다 📝 바이트코드 : 각 명령어는 1바이트 크기의 Opcode와 추가 피연산자로 이루어져 있는 파일 (컴퓨터가 읽을 수 없음) 📝 인터프리터 : 바이트 코드 .. 2023. 2. 8.