Spring Boot项目pom.xml添加Azure SDK依赖及相关插件找不到问题求助
解决方案
1. 修正BOM依赖的放置位置
Maven中scope=import的BOM依赖必须放在<dependencyManagement>节点下,不能直接放在普通<dependencies>节点中,且BOM声明顺序要早于其他Azure相关依赖,才能正常管理子依赖版本。你当前的POM直接将BOM放在普通依赖列表中,是子依赖无法正常引入的核心原因。
2. 调整后的POM参考配置
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.test</groupId> <artifactId>tesrt</artifactId> <version>1.0.0</version> <packaging>jar</packaging> <name>tesrt</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <jbcrypt.version>0.4</jbcrypt.version> <java.version>1.8</java.version> <azure.sdk.bom.version>1.0.4</azure.sdk.bom.version> </properties> <!-- 新增dependencyManagement节点放置BOM --> <dependencyManagement> <dependencies> <dependency> <groupId>com.azure</groupId> <artifactId>azure-sdk-bom</artifactId> <version>${azure.sdk.bom.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <profiles> <profile> <id>dev</id> <properties> <activatedProperties>dev</activatedProperties> </properties> </profile> <profile> <id>prod</id> <properties> <activatedProperties>prod</activatedProperties> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> </profiles> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.4.RELEASE</version> </parent> <dependencies> <!-- AZURE SDK 无需写版本号,由BOM统一管理 --> <dependency> <groupId>com.azure</groupId> <artifactId>azure-storage-queue</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>com.twilio.sdk</groupId> <artifactId>twilio</artifactId> <version>7.47.3</version> </dependency> </dependencies> <!-- 补充插件仓库配置,解决插件找不到问题 --> <pluginRepositories> <pluginRepository> <id>central</id> <url>https://repo1.maven.org/maven2/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> <!-- 普通依赖仓库配置,替换原有http地址 --> <repositories> <repository> <id>central</id> <url>https://repo1.maven.org/maven2/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> </project>
3. 修正Maven仓库地址
你当前配置的http://maven.apache.org/maven2是废弃的HTTP地址,Maven中央仓库已全面强制使用HTTPS,所以需要将POM或settings.xml中的仓库地址替换为https://repo1.maven.org/maven2/,如果使用私服,需要确认私服已同步Azure相关依赖包。
4. 清理本地缓存重试
如果之前拉取过失败的依赖缓存,执行以下命令强制更新依赖:mvn clean install -U
如果仍报错,可手动删除本地Maven仓库中com/azure路径下的所有文件,再重新执行构建命令。
5. 插件无法找到的处理
- 插件的拉取仓库独立于普通依赖仓库,上述POM中已补充
pluginRepositories配置,可直接复用 dependencyChecker-maven-plugin需确认版本号正确,若仍拉取失败,可排查是否为私服屏蔽了该插件的同步。
内容的提问来源于stack exchange,提问作者Nesan Mano
相关产品推荐
相关产品推荐

