springbott项目中如何让给子工程添加子工程的依赖
时间: 2024-02-18 14:01:57 浏览: 14
在 Spring Boot 项目中,可以使用 Maven 或 Gradle 来给子工程添加依赖。
如果你使用 Maven,你可以在子工程的 pom.xml 文件中添加依赖,例如:
```xml
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-library</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
```
如果你使用 Gradle,你可以在子工程的 build.gradle 文件中添加依赖,例如:
```groovy
dependencies {
implementation 'com.example:example-library:1.0.0'
}
```
需要注意的是,如果子工程需要依赖父工程中的某些模块,你需要在子工程的 pom.xml 或 build.gradle 中添加对父工程的依赖,例如:
Maven:
```xml
<parent>
<groupId>com.example</groupId>
<artifactId>example-parent</artifactId>
<version>1.0.0</version>
</parent>
```
Gradle:
```groovy
parent {
group = 'com.example'
version = '1.0.0'
artifactId = 'example-parent'
}
```