springboot 依赖的父工程 及 web的 依赖

一、依赖父工程:spring-boot-starter-parent

二、web项目依赖:spring-boot-starter-web;会自动将所有需要的依赖添加到仓库,避免依赖冲突的问题

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你可以使用 Maven 或 Gradle 来解决子工程没有工程的 Spring Boot 依赖的问题。以下是针对 Maven 的解决方案: 1. 在工程的 pom.xml 文件中,将 Spring Boot Starter Parent 作为项目的依赖。可以通过在 `<parent>` 标签中指定 Spring Boot 的版本来实现: ``` <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.5.4</version> </parent> ``` 请确保选择与你项目中其他模块使用的 Spring Boot 版本一致的版本号。 2. 在子工程的 pom.xml 文件中,将工程设置为当前项目的项目: ``` <parent> <groupId>your.parent.groupId</groupId> <artifactId>your.parent.artifactId</artifactId> <version>your.parent.version</version> </parent> ``` 请将 `your.parent.groupId`、`your.parent.artifactId` 和 `your.parent.version` 替换为真实的工程信息。 3. 确保子工程依赖中包含您需要使用的 Spring Boot Starter,例如: ``` <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- 其他依赖 --> </dependencies> ``` 4. 对于多模块项目,您还需要在子工程的 pom.xml 文件中定义模块之间的依赖关系。例如,如果子工程 B 依赖于子工程 A,可以在子工程 B 的 pom.xml 中添加以下依赖项: ``` <dependencies> <dependency> <groupId>your.groupId</groupId> <artifactId>module-a</artifactId> <version>your.version</version> </dependency> <!-- 其他依赖 --> </dependencies> ``` 请将 `your.groupId`、`module-a` 和 `your.version` 替换为实际的模块信息。 完成上述步骤后,运行 Maven 构建命令或导入项目到 IDE 中,子工程将会继承工程中的 Spring Boot 依赖。这样,您就可以在子工程中使用 Spring Boot 相关的功能了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值