Mybatis-plus 와 pagehelper 의존 충돌 을 해결 하 는 방법 예시

간단 한 소개
MyBatis-Plus(MP 로 약칭)는 하나 입 니 다. MyBatis 의 증강 도 구 는 MyBatis 의 기초 위 에서 증강 만 하고 변 하지 않 으 며 개발 을 간소화 하고 효율 을 높이 기 위해 생 겨 났 다.
시작 하면 기본 CURD 를 자동 으로 주입 하고 성능 은 기본적으로 손실 이 없 으 며 대상 을 대상 으로 직접 조작 합 니 다.
Mybati-plus 자체 에 페이지 기능 이 있 지만 저 는 개인 적 으로 pagehelper 를 사용 하여 페이지 를 나 누 었 습 니 다.그래서 pom 에 pagehelper 의존 도 를 추 가 했 습 니 다.그러나 프로젝트 를 실행 한 후에 jar 가방 충돌 을 발 견 했 습 니 다.충돌 에 직면 하여 우 리 는 어떻게 해결 해 야 합 니까?다음 내용 을 보면 쉽게 해결 할 수 있 습 니 다.
의존

        <!-- mbatis-plus -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.1.2</version>
        </dependency>
 
        <!--generator-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-generator</artifactId>
            <version>3.1.2</version>
 
        </dependency>
 
     
        <!-- pagehelper-->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.2.5</version>
         </dependency>
실행 항목
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder.getLanguageDriver(MybatisMapperAnnotationBuilder.java:369)
The following method did not exist:
com.baomidou.mybatisplus.core.MybatisConfiguration.getLanguageDriver(Ljava/lang/Class;)Lorg/apache/ibatis/scripting/LanguageDriver;
The method's class, com.baomidou.mybatisplus.core.MybatisConfiguration, is available from the following locations:
jar:file:/Applications/MrWang/Maven/privite_wang_repository/com/baomidou/mybatis-plus-core/3.1.2/mybatis-plus-core-3.1.2.jar!/com/baomidou/mybatisplus/core/MybatisConfiguration.class
It was loaded from the following location:
file:/Applications/MrWang/Maven/privite_wang_repository/com/baomidou/mybatis-plus-core/3.1.2/mybatis-plus-core-3.1.2.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of com.baomidou.mybatisplus.core.MybatisConfiguration
Disconnected from the target VM, address: '127.0.0.1:55790', transport: 'socket'
Process finished with exit code 0
프로그램의 클래스 경 로 를 수정 하여 com.baomidou.my batisplus.core.MybatisConfiguration 의 단일 호 환 버 전 을 포함 하도록 합 니 다.

빨간색 이 표 시 된 부분 은 회색 이 고 뒤의 괄호 안의 뜻 을 보 세 요. ),이 가방 은 위의 가방 과 똑 같 습 니 다.위 에는 밝 고 아래 는 회색 입 니 다.시스템 이 위의 jar 가방 을 사용 하여 아래 의 jar 가방 이 충돌 을 알 리 는 것 을 설명 합 니 다.그런데 왜 아래 의 것 을 사용 하지 않 고 개인 적 으로 시간 을 들 여 연 구 를 합 니 다.물론 우리 의 목적 은 이 충돌 을 해결 하 는 것 이 아 닙 니 다.이것 은 시스템 에 의 해 감지 되 었 기 때문에 시스템 이 자동 으로 하 나 를 사용 하지 않 습 니 다.우 리 는 시스템 에서 감지 할 수 없 는 충돌 을 해결 해 야 한다.
끌어들이다  MyBatis-Plus  그 다음 에는 다시 들 어 오지 마 세 요.  MyBatis  그리고  MyBatis-Spring버 전 차이 로 인 한 문 제 를 피한다.(Mybatis-plus 홈 페이지
pagehelper 의존 가방 은 위의 그림 에서 알 수 있 듯 이 4.567914 도 포함 되 어 있 습 니 다. 그리고 MyBatis-Spring,MyBatis-Spring 은 충돌 에 의존 합 니 다.시스템 은 Mybatis-plus 의 MyBatis-Spring 을 자동 으로 사용 합 니 다.따라서 우 리 는 pagehelper 의 my batis 를 삭제 에 의존 하면 됩 니 다.구체 적 인 조작 은 다음 과 같 습 니 다.
version 아래 에 exclusions 의존 추가(제외)

 <!-- pagehelper-->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.2.5</version>
            <exclusions>
                <exclusion>
                    <groupId>org.mybatis</groupId>
                    <artifactId>mybatis</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
항목 재 부팅 및 테스트
postman 테스트 결과

 문제 가 완벽 하 게 해결 되 었 다
Mybatis-plus 와 pagehelper 의 충돌 의존 을 해결 하 는 방법 에 대한 예 시 를 소개 합 니 다.더 많은 Mybatis-plus 와 pagehelper 의 충돌 의존 내용 은 우리 의 이전 글 을 검색 하거나 아래 의 관련 글 을 계속 조회 하 시기 바 랍 니 다.앞으로 도 많은 지원 을 바 랍 니 다!

좋은 웹페이지 즐겨찾기