maven的相关使用

build属性

  • 使用maven构建的项目可以直接使用maven build完成项目的编译、测试、打包,无需额外配置。

  • build标签描述了如何编译及打包项目,具体的编译和打包工作是通过其中的plugin配置来实现的。当然,plugin不是必须的,即使不添加默认也会引入以下插件:
    在这里插入图片描述

  • 如果有需要可以另外进行配置,以下配置了编译时使用的jdk版本。 因为maven默认使用JDK5版本的,如果我们需要按照JDK8以及以上进行编译,我们需要使用properties里面的JDK版本

<!--一般我们在properties里面指定JDK的版本和依赖的版本-->
    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

deploy属性

IDEA配置连接(自建Maven仓库)私服并打包上传

<server>    
        <id>privete_maven</id>
        <!--账号密码需要与私服登录账号密码一致-->
        <username>admin</username>
        <password>123456</password>
    </server>

在项目的pom.xml文件增加 这里的ID要和上面的ID对应
在这里插入图片描述

    <distributionManagement>
        <repository>
            <id>privete_maven</id>
            <name>Nexus Release Repository</name>
            <url>http://192.168.1.2:8010/nexus/repository/maven-releases/</url>
        </repository>
    </distributionManagement>

然后点击idea的右上角的deploy按键
在这里插入图片描述

maven的包路径依赖原则

  1. 依赖路径最短优先原则
  2. 声明顺序优先原则
  3. 覆写优先原则: 子 POM 内声明的依赖优先于父 POM 中声明的依赖。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值