Maven中<scope>中等级的区别

标签指定了依赖项的级别吗,默认是compile (编译)。意味着依赖项将会在编译时和运行时都被包含在项目中

<scope> 标签指定了依赖项的级别为 import 。除了 import 级别,Maven还支持以下几种级别:

  1. compile (编译):默认级别,表示依赖项在编译时需要被包含。

  2. provided (提供):表示依赖项在编译时需要被包含,但在运行时由目标环境(例如应用服务器)提供。

  3. runtime (运行时):表示依赖项在运行时需要被包含,但在编译时不需要。

  4. test (测试):表示依赖项仅在执行测试时需要被包含,不会在主应用程序中使用。

  5. system (系统):表示依赖项是在本地文件系统中手动提供的,而不是从Maven仓库中获取。

import 和compile 两者有什么区别

在Maven中, importcompile 是两个不同的依赖级别,它们之间有以下区别:

  1. compile 级别:表示依赖项在编译时需要被包含,同时也需要在运行时被包含。它是默认的依赖级别。

  2. import 级别:表示依赖项不会直接被包含在项目中,而是用于导入其他POM文件中声明的依赖项。它通常用于管理项目中的公共依赖项,以避免在多个模块中重复声明。

因此, compile 级别和 import 级别的主要区别在于它们在项目构建过程中的作用不同。 compile 级别的依赖项会被编译和打包到项目中,而 import 级别的依赖项只是用于管理其他依赖项,不会被直接包含在项目中。

如果您觉得我所提供的信息对您有帮助,欢迎您点赞、收藏和评论。如果您想要更深入的交流,您可以添加我的微信号,或者关注我的微信公众号。您的支持和鼓励是我持续写作的动力,我期待与您互动并提供更多有价值的信息。

<?xml version="1.0" encoding="UTF-8"?> <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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.6.7</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.gientech</groupId> <artifactId>permission-review</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>pom</packaging> <name>permission-review</name> <description>permission-review</description> <modules> <module>permission-review-admin</module> <module>permission-review-middleware</module> </modules> <properties> <java.version>8</java.version> </properties> <dependencies> <!-- 排除 Spring Boot 默认的日志实现 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- MyBatis --> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.2.2</version> 版本有什么问
03-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

舒一笑不秃头

你的鼓励是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值