• 2022年0902Maven的依赖学习<第四课>


    f55d6ac4dc1d4485a78427e8cb7f0c41.png

    第一部分 Maven的依赖的学习内容介绍

    第一点  依赖的范围

    1 依赖范围 Scope

    标签的位置:dependencies/dependency/scope

    标签的可选值:compile/test/provided/system/runtime/import

    2 一张表告诉你Scope的范围介绍

    main目录(空间) test目录(空间) 开发过程(时间) 部署到服务器(时间)
    compile 有效 有效 有效 有效
    test 无效 有效 有效 无效
    provided 有效 有效 有效 无效

    3 总结:

    copile:通常使用的第三方框架的 jar 包这样在项目实际运行时真正要用到的 jar 包都是以 compile 范围进行依赖的。比如 SSM 框架所需jar包。**

    test:测试过程中使用的 jar 包,以 test 范围依赖进来。比如 junit。

    provided:在开发过程中需要用到的“服务器上的 jar 包”通常以 provided 范围依赖进来。比如 servlet-api、jsp-api。而这个范围的 jar 包之所以不参与部署、不放进 war 包,就是避免和服务器上已有的同类 jar 包产生冲突,同时减轻服务器的负担。说白了就是:“服务器上已经有了,你就别带啦!”

    4 观察

    1. This XML file does not appear to have any style information associated with it. The document tree is shown below.
    2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    3. <modelVersion>4.0.0modelVersion>
    4. <groupId>com.web.mavengroupId>
    5. <artifactId>pros-web01-mavenartifactId>
    6. <version>1.0-SNAPSHOTversion>
    7. <packaging>warpackaging>
    8. <name>pros-web01-maven Maven Webappname>
    9. <url>http://www.example.comurl>
    10. <properties>
    11. <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
    12. <maven.compiler.source>1.7maven.compiler.source>
    13. <maven.compiler.target>1.7maven.compiler.target>
    14. properties>
    15. <dependencies>
    16. <dependency>
    17. <groupId>junitgroupId>
    18. <artifactId>junitartifactId>
    19. <version>4.12version>
    20. <scope>testscope>
    21. dependency>
    22. <dependency>
    23. <groupId>javax.servletgroupId>
  • 相关阅读:
    iNFTnews | NFT在门票领域会有哪些作用?
    书桌台灯怎么选?分享儿童卧室灯品牌
    stm32--独立看门狗
    十万个Web3为什么:TRON (TRX)是个什么鬼?
    vertx学习总结5
    call、bind、apply的作用与区别
    [近两万字] MySQL大全
    医疗图像自动轮廓勾画
    Java开发手册①
    vue-video-play使用之播放hls格式视频
  • 原文地址:https://blog.csdn.net/qq_56248592/article/details/126669488