zoukankan      html  css  js  c++  java
  • Maven依赖排除及版本统一

    依赖排除

    <dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-core</artifactId>
    	<version>5.0.0.RELEASE</version>
    	<!-- 依赖排除 -->
    	<exclusions>
    	    <exclusion>
    	        <groupId>commons-logging</groupId>
    		<artifactId>commons-logging</artifactId>
    	    </exclusion>
    	</exclusions>
    </dependency>
    
    

    版本统一

    方法一:通过<properties>实现

    <!--控制spring的版本-->
    <properties>
            <!--标签名可以自己定义-->
    	<spring.version>5.0.0.RELEASE</spring.version>
    </properties>
    <dependencies>
    	<dependency>
    	    <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <!--获得版本信息-->
                <version>${spring.version}</version>
    	</dependency>
    </dependencies>
    

    方法二:通过继承实现

    maven项目类型(<packaging>):

    • pom用于声明父工程
    • jar(默认值,可以省略)用于声明java工程
    • war用于声明web工程
    <!--父工程-->
    	<!--父工程坐标-->
    	<groupId>com.maven</groupId>
    	<artifactId>parent</artifactId>
    	<version>0.0.1-SNAPSHOT</version>
            <!--表明当前工程是一个父工程-->
    	<packaging>pom</packaging>
    
    	<dependencyManagement>
    	    <dependencies>
    		<dependency>
    		    <groupId>junit</groupId>
    		    <artifactId>junit</artifactId>
    		    <version>4.10</version>
    		    <scope>test</scope>
    	        </dependency>
    	    </dependencies>
    	</dependencyManagement>
    
    <!--子工程-->
    	<!--继承父工程-->
    	<parent>
    	    <groupId>com.maven</groupId>
    	    <artifactId>parent</artifactId>
    	    <version>0.0.1-SNAPSHOT</version>
                <!--父工程pom文件的路径-->
    	    <relativePath>../parent/pom.xml</relativePath>
    	</parent>
    	<dependencies>
    	    <dependency>
                <!--子工程只需要注明需要引用的依赖即可,版本号由父工程控制-->
    	        <groupId>junit</groupId>
    		<artifactId>junit</artifactId>
                </dependency>
    	</dependencies>
    
    
    
  • 相关阅读:
    ubuntu 搭建 php 环境
    【转】送给和我一样曾经浮躁过的PHPer程序猿,希望有帮助
    thinkphp iis下去掉index.php
    windows定时执行PHP的技巧
    js 生成随机数字的方法
    Linux下crontab命令的用法
    收藏下(设为收藏,设为首页)
    C#扩展方法的理解
    Win7 访问共享时输入正确密码仍然提示密码错误
    SQL Server 获取插入记录后的自动编号ID
  • 原文地址:https://www.cnblogs.com/xlwq/p/12614524.html
Copyright © 2011-2022 走看看