06Maven版本冲突解决方案实例

<properties>
        <spring.version>
            4.2.4.RELEASE
        </spring.version>
    </properties>
    <!-- 版本锁定 -->
    <dependencyManagement>
        <dependencies>
            
            <dependency>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-beans</artifactId> 
                    <version>${spring.version}</version>
            </dependency>
            
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>${spring.version}</version>
        </dependency>
        
        </dependencies>
    </dependencyManagement>
    
    
    <build>
        <!-- 配置了很多插件 -->
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <path>/f</path>
                </configuration>
            </plugin>
        </plugins>
    </build>


    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
            <version>4.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-core</artifactId>
            <version>2.3.24</version>
        </dependency>

        <!-- spring-bean用的是3.0.5版本 -->
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-spring-plugin</artifactId>
            <version>2.3.24</version>
            <!-- 排除冲突版本的jar包 -->
            <!-- <exclusions> <exclusion> 
                    <groupId>org.springframework</groupId> 
                    <artifactId>spring-beans</artifactId> 
                </exclusion> </exclusions> -->
        </dependency>
        <!-- spring-bean用的是4.2.4版本 -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <!-- 为了解决这个冲突,自行添加spring-beans 4.2.4的约束 -->
        <!-- <dependency> 
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId> 
            <version>4.2.4.RELEASE</version>
         </dependency> -->
    </dependencies>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容