展开
拓展 关闭
订阅号推广码
GitHub
视频
公告栏 关闭

依赖管理

  • 导入依赖
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
  • 将项目3作为依赖导入到项目2中
<dependency>
<groupId>com.itheima</groupId>
<artifactId>project03</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
  • 依赖具有传递性

  • 依赖冲突问题

  • 当项目3作为依赖导入到项目2后,可以在项目2中查看项目3拥有的依赖,如果项目3不希望项目2看到自己的依赖

# 在项目3中可以在导入依赖时设置为不透明
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<optional>true</optional>
</dependency>
  • 当1个项目导入依赖后,这个依赖也依赖了其他的依赖,如果想排除该依赖中的其他依赖
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>

  • 依赖范围传递性

  • 如果项目3作为依赖导入到项目2,项目3中的某个依赖的范围为runtime,项目2中某个相同的依赖的范围是test,那么在项目2中看到的依赖范围是test

  • 这里的项目3是间接依赖,项目2是直接依赖

posted @   DogLeftover  阅读(17)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术
点击右上角即可分享
微信分享提示