복붙노트

[SPRING] 이전 버전의 Maven 종속성을 제외하고 새 버전을 사용하는 방법

SPRING

이전 버전의 Maven 종속성을 제외하고 새 버전을 사용하는 방법

나는 Maven 프로젝트와 함께 일하고 있는데 ProjectA와 ProjectB의 두 프로젝트가 있습니다. 내 ProjectA는 pom이 다음과 같이 보이는 maven 라이브러리입니다.

<?xml version="1.0" encoding="UTF-8"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.texture.partial</groupId>
        <artifactId>PartialPlatform</artifactId>
        <version>2.1.5-RELEASE</version>
    </parent>

    <groupId>com.texture.transform.golden</groupId>
    <artifactId>SampleClient</artifactId>
    <version>1.0.4</version>

    <dependencies>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.4</version>
        </dependency>
        <dependency>
            <groupId>com.texture.partial.core</groupId>
            <artifactId>PartialKernel</artifactId>
        </dependency>
        <dependency>
            <groupId>com.texture.webres</groupId>
            <artifactId>WebResPartial</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.texture.kernel</groupId>
            <artifactId>TextureServer</artifactId>
        </dependency>
        <dependency>
            <groupId>com.texture.kernel</groupId>
            <artifactId>Kernel</artifactId>
        </dependency>
        <dependency>
            <groupId>com.texture.v3jars.Houston</groupId>
            <artifactId>KernelDAL</artifactId>
        </dependency>
        <dependency>
            <groupId>com.texture.kernel</groupId>
            <artifactId>uKernel</artifactId>
        </dependency>
        <dependency>
            <groupId>com.texture.kernel</groupId>
            <artifactId>uKernelCore</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-asm</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>aopalliance</groupId>
            <artifactId>aopalliance</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.bundles</groupId>
            <artifactId>org.apache.servicemix.bundles.cglib</artifactId>
        </dependency>
        <dependency>
            <groupId>com.texture.partial.core</groupId>
            <artifactId>ConfigWeb</artifactId>
        </dependency>
        <dependency>
            <groupId>com.texture.partial.core</groupId>
            <artifactId>PartialWeb</artifactId>
        </dependency>
        <dependency>
            <groupId>com.googlecode.jmockit</groupId>
            <artifactId>jmockit</artifactId>
            <version>1.7</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>-javaagent:"${settings.localRepository}"/com/googlecode/jmockit/jmockit/1.7/jmockit-1.7.jar</argLine>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <configuration>
                    <instrumentation>
                        <excludes>
                            <exclude>**/test/**/*.class</exclude>
                        </excludes>
                    </instrumentation>
                    <formats>
                        <format>xml</format>
                        <format>html</format>
                    </formats>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

위의 pom에서 PartialKernel은 spring-core, spring-web과 같은 다양한 Spring Framework 종속성의 이전 버전을 가져오고 있습니다. 3.2.8.RELEASE 버전을 가져오고 있습니다. 4.1.6.RELEASE 인 두 가지 스프링 프레임 워크의 최신 버전을 사용하고 싶습니다. PartialKernel에서 제공되는 스프링 - 코어 및 스프링 - 웹의 이전 버전을 제외하고 최신 버전을 사용하는 올바른 방법은 무엇입니까?

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>4.1.6.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>4.1.6.RELEASE</version>
    </dependency>

일부 수업은 최신 버전에만 있기 때문에 최신 버전을 사용해야합니다.

해결법

  1. ==============================

    1.종속성에 필요한 라이브러리 버전과 사용할 라이브러리 버전 간에는 호환되지 않는 차이가있을 수 있습니다. 이 위험 부담을 감당할 수 있다면 maven 제외를 사용하여 이행 적 종속성을 무시할 수 있습니다.

    종속성에 필요한 라이브러리 버전과 사용할 라이브러리 버전 간에는 호환되지 않는 차이가있을 수 있습니다. 이 위험 부담을 감당할 수 있다면 maven 제외를 사용하여 이행 적 종속성을 무시할 수 있습니다.

    예를 들어 Spring Core가 PartialKernel에 포함되지 않도록 다음을 추가하여 제외 할 수 있습니다.

    <dependency>
        <groupId>com.texture.partial.core</groupId>
        <artifactId>PartialKernel</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    

    스프링 종속성을 초래하는 모든 종속성에 대해이 작업을 수행해야합니다.

    이제 최상위 수준의 pom 의존성 관리 섹션에서 사용할 스프링 코어의 버전을 정의하십시오.

    <dependencyManagement>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>4.1.6.RELEASE</version>
        </dependency>
    </dependencyManagement>
    
  2. from https://stackoverflow.com/questions/29738112/how-to-exclude-older-versions-of-maven-dependency-and-use-new-version-of-it by cc-by-sa and MIT license