반응형

Framework/Spring Boot 69

[Error] Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource

의존성에 mysql-connector-j를 빼먹으면 다음과 같은 로그가 나온다. 초기에 dependencies를 구성할 때 실수로라도 빼먹지말자!!!! org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'data..

트랜잭션

⭐ 트랜잭션 DB 상태를 변환시키는 한 번에 수행되어야 할 일련의 연산 수행 단위 작업을 수행하던 도중 문제가 발생하면 이전에 진행되었던 작업도 취소됨 Rollback 트랜잭션이 비정상적으로 종료되면 모든 연산을 취소해서 DB에 반영하지 않음 커밋 트랜잭션의 작업이 정상적으로 끝나면 DB에 반영 성질 Atomicity 하나의 트랜잭션은 최소의 단위 Consistency 트랜잭션의 일부가 DB에 commit되었을 때 트랜잭션의 범위에 있는 다른 연산들도 commit 되는 것을 보장 Isolation 다른 트랜잭션의 연산작업이 기존 작업에 영향을 주지 못한다. Durability 트랜잭션을 처리한 후 DB에 반영된 내용은 영원히 지속됨 상태 Active 진행 중 Partially Committed 연산을 모..

OAuth2User

public interface OAuth2User extends OAuth2AuthenticatedPrincipal OAuth 2.0 provider에 등록된 user principal을 표시 OAuth 2.0 사용자는 하나 이상의 속성들로(예를 들어, first name, middle name, last name, 이메일, 연락처, 주소 등) 구성된다. 각 사용자 속성은 name, value를 가지고 있고 OAuth2AuthenticatedPrincipal.getAttributes()의 name에 의해 키 입력된다. 속성 이름은 providers 간에 표준화되지 않으므로 다르다. 이 인터페이스의 구현 인스턴스는 인증 객체와 연결되어 Authentication.getPrincipal()을 통해 액세스할 ..

[Error] ModelMapper 매핑이 안될 때

.setFieldMatchingEnabled(true) ModelMapper 빈을 등록할 때 설정해주자. Field matching은 필드를 매칭시킬 수 있는지를 나타낸다. 기본값은 disabled로 설정되어있다. 참고 👇 http://modelmapper.org/user-manual/configuration/ ModelMapper - Configuration Configuration ModelMapper uses a set of conventions and configuration to determine which source and destination properties match each other. Available configuration, along with default values, is..

ModelMapper Matching Strategy 정리

Matching Strategy Standard 기본값 MatchingStrategies.STANDARD Token들은 임의의 순서로 매칭될 수 있다. 모든 destination 속성 이름 토큰이 무조건 매칭되어야 한다. 모든 source 속성명에 매칭될 토큰이 하나 이상 있어야 한다. 정확하지 않은 반면에 대부분의 상황에서 이상적이다. Loose MatchingStrategies.LOOSE Token들은 임의의 순서로 매칭될 수 있다. 마지막 destination 속성 이름은 모든 토큰이 매칭되어야 한다. 마지막 source 속성 이름에는 매칭될 토큰이 하나 이상 있어야 한다. 매우 다른 속성 계층을 가진 source와 destination 개체 모델에 사용하는 것이 이상적이다. 더 높은 수준의 모호한..

[Spring Security] rememberMe 설정

Spring Security가 제공하는 Remember Me는 시스템이 사용자를 기억하고 세션이 만료된 후 자동으로 로그인해준다. 해시를 사용해 쿠키 기반의 토큰의 보안을 유지하거나 데이터베이스 또는 다른 영구 저장 메커니즘을 사용한다. .and() .logout().deleteCookies("JSESSIONID") .and() .rememberMe().key("uniqueAndSecret").tokenValiditySeconds(86400); configure 메소드에 추가해주었다. 기본 만료 기간은 2주지만, tokenValiditySeconds 메소드로 만료 기간을 하루로 설정했다. Remember Me 쿠키는 username, expirationTime, MD5hash를 담고있다. MD5 hash..

[Error] Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported Form을 submit으로 서버에 요청을 보내면서 발생한 에러다. 이전에는 AJAX로 요청을 보내서 @RequestBody가 컨트롤러에서 있었다. 하지만, submit으로 요청을 보내게 되면 @RequestBody가 필요없고 위와 같은 에러가 생긴다. 더이상 쓸모없는 @RequestBody를 없애면 에러가 해결된다. 👇 참고 https://stackoverflow.com/questions/33796218/content-type-application-x-www-form-urlencodedcharset-utf-8-not-supported-for Content type 'a..

업로드 파일 사이즈

org.apache.tomcat.util.http.fileupload.impl.FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1048576 bytes. 이미지 파일 하나 업로드하니까 다음과 같은 에러 발생 기본값이 1048576 bytes 🌿 해결 spring.servlet.multipart.max-file-size=5MB spring.servlet.multipart.max-request-size=10MB build.gradle에 추가하자. max-file-size는 허용 가능한 최대 바이트 사이즈다. 업로드한 파일 중에서 max-file-size를 초과하는 파일이 있다면, IllegalStateEx..

반응형