排除dependencyManagement中spring-boot-dependencies中的依赖方法

本文介绍如何在项目中正确配置Spring Boot依赖及Netty BOM版本。通过示例展示了如何使用Maven进行管理,并确保版本的一致性。
<dependencyManagement>
   <dependencies>
      <dependency>
         <groupId>io.netty</groupId>
         <artifactId>netty-bom</artifactId>
         <version>4.1.72.Final</version>
         <type>pom</type>
         <scope>import</scope>
      </dependency>
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-dependencies</artifactId>
         <version>${spring-boot-dependencies.version}</version>
         <type>pom</type>
         <scope>import</scope>

      </dependency>
   </dependencies>

要加在引入springboot依赖之前

<?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>3.5.5</version> <relativePath/> </parent> <groupId>cn.ac.cncb</groupId> <artifactId>pathogen-convergence-system</artifactId> <version>0.0.1-SNAPSHOT</version> <name>pathogen-convergence-system</name> <description>pathogen-convergence-system</description> <properties> <java.version>17</java.version> <mybatis-plus.version>3.5.5</mybatis-plus.version> <mysql.version>8.4.0</mysql.version> <opencsv.version>5.6</opencsv.version> <swagger.version>2.5.0</swagger.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> <!-- Spring Boot Web --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency> <!-- Spring Boot 配置处理器 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency> <!-- Swagger/OpenAPI (API文档) --> <dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> <version>${swagger.version}</version> </dependency> <!-- MySQL 驱动 --> <dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-j</artifactId> <version>${mysql.version}</version> <scope>runtime</scope> </dependency> <!-- MyBatis-Plus --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>${mybatis-plus.version}</version> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency> <!-- MyBatis-Plus 分页插件(如果需要分页) --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-extension</artifactId> <version>${mybatis-plus.version}</version> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency> <!-- Spring Data Redis --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency> <!-- OpenCSV 依赖 --> <dependency> <groupId>com.opencsv</groupId> <artifactId>opencsv</artifactId> <version>${opencsv.version}</version> <!-- 稳定版本,兼容Java 17 --> </dependency> <!-- 添加 Log4j2 依赖 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-log4j2</artifactId> </dependency> <!-- Lombok --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <!-- 测试依赖 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency> <!-- 阿里 Fastjson2 --> <dependency> <groupId>com.alibaba.fastjson2</groupId> <artifactId>fastjson2</artifactId> <version>2.0.53</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project> 检查一下这个pom文件。看看哪里有问题
09-15
### 解决 Maven 项目中无法解析 `spring-boot-dependencies` 文件的方法 当遇到无法解析 `spring-boot-dependencies` 文件的问题时,通常是因为项目的配置或环境设置存在问题。以下是几种可能的原因及解决方案: #### 检查仓库配置 确保本地或远程仓库已正确配置,并能够访问 Spring Boot 的官方仓库。如果使用的是公司内部镜像库,则需确认该镜像库已经同步了所需的依赖。 ```xml <repositories> <repository> <id>central</id> <url>https://repo.maven.apache.org/maven2/</url> </repository> </repositories> ``` #### 更新依赖管理部分中的版本号 有时可能是由于指定了错误的 `spring-boot-dependencies` 版本所引起的。应核对并更新至最新稳定版或其他所需的具体版本[^2]。 ```xml <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>${spring-boot.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> ``` #### 清理和重新构建项目 尝试清理本地缓存以及执行完整的编译过程来排除潜在干扰因素。可以利用命令行工具完成此操作: ```shell mvn clean install -U ``` 上述 `-U` 参数会强制刷新过期的快照依赖项,从而有助于获取最新的元数据信息。 #### 验证网络连接状况 考虑到某些情况下外部资源不可达也会造成此类现象的发生,因此建议测试当前机器对外部站点(如 https://repo.spring.io)是否有正常响应时间。 通过以上措施应该能有效处理大多数关于 “无法解析 spring-boot-dependencies” 的情况;若依旧存在困难则可进一步排查其他方面的影响要素,比如防火墙策略限制等特殊场景下的约束条件[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值