Web27 [Mapper] MapStruct로 Dto/Entity 매핑하기(vs ModelMapper) 스터디원 중에 한 분이 엔티티매퍼 알려주셔서 와 신세계다 이러고 쓰고 있었는데 예전 프로젝트들 까보니까 익숙하게 ModelMapper 쓰고 있었음...... 스프링 너무 간만인데다 어디 기록도 안 해두니까 다 까먹는다. 그런데 기존에 사용하던 ModelMapper는 modelMapper.map(ENTITY, DTO.Class) 형태로 사용할 때 리플렉션이 일어나서 MapStruct보다 성능이 떨어진다고 한다. 그래서 이번 프로젝트부터는 MapStruct를 사용하기로 했다. 알려주셔서 감사합니다. mapstruct는 프로젝트를 빌드하면 mapstruct의 @Mapper가 달린 interface의 구현클래스를 자동으로 생성해 준다. pom.xml 1.4.2.Final 0.2.0 org.mapstruct ma.. 2021. 11. 7. [Mybatis/Pagination] PageHelper로 Paging처리하기 JPA에서는 JpaRepository가 PagingAndSortingRepository를 상속하고 있어서 쉽게 페이징을 처리할 수 있었지만 Mybatis의 경우 다른 방법이 필요했다. 수동으로 구현하기에는 품이 들어서 라이브러리를 쓰기로 함. 공식 깃헙 https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/en/HowToUse.md GitHub - pagehelper/Mybatis-PageHelper: Mybatis通用分页插件 Mybatis通用分页插件. Contribute to pagehelper/Mybatis-PageHelper development by creating an account on GitHub. github.com pom... 2021. 11. 7. [Maven/Eclipse] 빌드 시 target/generated-sources 인식 못 하는 문제 mapstruc를 써보려고 하는데 build해서 정상적으로 MapperImpl클래스가 생성된 것까지는 확인했다. 그런데 테스트를 돌려보니까 Impl클래스를 못 찾아내는 문제를 발견함 Impl클래스는 /target/generated-sources/annotation/${프로젝트 패키지} 아래 생성됨 뭐가 문젠가 찾아보다가ㅋㅋ 다른 블로그에서 보여주는 빌드 경로가 내 것과 다른 걸 발견함 그래서 maven target generated-sources 키워드 잡고 찾았더니 빌드 소스를 따로 잡아줘야 한다는 글이 나왔다 https://stackoverflow.com/questions/19633505/why-are-maven-generated-sources-not-getting-compiled Why are Ma.. 2021. 11. 7. [Maven] 최초 build시 잡아야 하는 configuration Profile 설정 The requested profile "pom.xml" could not be activated because it does not exist. maven build할 때 뜨는 configuration 창에서 profile부분을 보면 "pom.xml"이 써 있다. 얘가 왜 들어가 있는지 모르겠는데 지워주면 해결된다. DefaultGoal 설정 No goals have been specified for this build gradle이랑 달리 maven은 goal을 설정해줘야 build가 가능하다고 한다. pom.xml에 default goal을 추가해주거나 edit configuration에 install을 추가해주자... install Goal 종류 https://choiseonj.. 2021. 11. 7. [Test] 실제 DB로 @DataJpaTest 돌리면 뜨는 "Failed to replace DataSource with an embedded database for tests" 에러 마이바티스랑 JPA를 혼용해서 써보려는데 테스트 단계에서 에러가 떴다. Failed to replace DataSource with an embedded database for tests. If you want an embedded database please put a supported one on the classpath or tune the replace attribute of @AutoConfigureTestDatabase. 테스트에 사용한 어노테이션은 다음과 같다. @ExtendWith(SpringExtension.class) @DataJpaTest public class AccountRepositoryTest { } 그런데 @DataJpaTest가 문제였음... 학습테스트용이라 밑단부터 확인해.. 2021. 11. 6. [Custom datasource] hikary.jdbc-url 쓰다가 Failed to configure a DataSource: 'url' 발생 *************************** APPLICATION FAILED TO START *************************** Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class datasource를 hikari로 설정했을 때 발생하는 오류다. 에러가 발생했을 때의 application.properties spring.datasource.hikari.driver-class-name=com.mysql.cj.jdbc.D.. 2021. 11. 6. 이전 1 2 3 4 5 다음 반응형