설치&설정 관련

[TIP]ModelMapper 사용시 다음 오류 발생시 확인 사항

lahuman 2015. 12. 16. 17:38
728x90

ModelMapper 사용시 다음 오류 발생시 확인 사항

오류내용

Request processing failed; nested exception is org.modelmapper.ConfigurationException: ModelMapper configuration errors:

1) The destination property kr.pe.lahuman.models.Comment.setId() matches multiple source property hierarchies:

kr.pe.lahuman.comment.CommentDTO$Request.getMainId()
kr.pe.lahuman.comment.CommentDTO$Request.getCodeId()

1 error
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.modelmapper.ConfigurationException: ModelMapper configuration errors:

오류 내용 번역

요청 진행 실패; org.modelmapper.ConfigurationException:ModelMapper configuration error: 오류가 잡혔다
1) 목적 요소 kr.pe.lahuman.models.Comment.setId() 의 소스 요소가 여러개가 발견:

    kr.pe.lahuman.comment.CommentDTO$Request.getMainId()
    kr.pe.lahuman.comment.CommentDTO$Request.getCodeId()

1 error
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.modelmapper.ConfigurationException: ModelMapper configuration errors:

원인

연결 전략이 기본 값의 경우 같은 타입을 사용하는 조건을 만족하는(ID) 값을 자동으로 연결 해주어 발생

해결 방안

연결 전략을 엄격하게 변경하여 같은 타입의 필드명 역시 같은 경우만 동작하도록 변경

modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);

참조 주소

ModleMapper 사용자 가이드-설정


MD FILE :

modelmapper_error.md




728x90