Framework/Spring Boot 75

[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..

[Error] Could not write JSON: Java 8 date/time type `java.time.LocalDateTime` not supported by default:

There was an unexpected error (type=Internal Server Error, status=500). Could not write JSON: Java 8 date/time type `java.time.LocalDateTime` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: java.util.ArrayList[0]->Bulletin.Board.domain.posts.Post["createdDate"]); nested exception is com.fasterxml.jackson.d..

[Error] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer'

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource [org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Unable to c..

[Error] java.lang.IllegalStateException: Failed to load ApplicationContext

java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration: Invocation of init method failed; nested exception is java.lang.NoSuchMethodErr..

[Error] org.springframework.data.redis.serializer.SerializationException

org.springframework.data.redis.serializer.SerializationException: Cannot serialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to serialize object using DefaultSerializer; nested exception is java.io.NotSerializableException: Bulletin.Board.domain.posts.Post Caused by: org.springframework.core.serializer.support.SerializationFailedExcepti..