Vaadin项目构建失败:PKIX路径构建错误排查求助
Vaadin项目构建PKIX证书路径错误排查方案
问题概述
构建Vaadin项目时持续出现PKIX证书路径错误,项目在其他Mac、Windows设备及同事机器上可正常构建,禁用工作VPN后问题仍存在。怀疑问题源于本地设备配置、代理限制或公司软件拦截。
报错信息
核心证书错误
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
XML Schema校验错误
cvc-elt.1.a: Cannot find the declaration of element 'project'.xml(cvc-elt.1.a)
Error while downloading 'http://maven.apache.org/xsd/maven-4.0.0.xsd' to '%HOME%\.lemminx\cache\http\maven.apache.org\xsd\maven-4.0.0.xsd' : '[sun.security.provider.certpath.SunCertPathBuilderException] unable to find valid certification path to requested target'
Maven依赖解析错误
Project build error: Non-resolvable parent POM for com.example.application:mytodo:1.0-SNAPSHOT: The following artifacts could not be resolved: org.springframework.boot:spring-boot-starter-parent:pom:3.1.0 (absent): org.springframework.boot:spring-boot-starter-parent:pom:3.1.0 failed to transfer from https://maven.vaadin.com/vaadin-addons during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of Vaadin Directory has elapsed or updates are forced. Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:3.1.0 from/to Vaadin Directory (https://maven.vaadin.com/vaadin-addons): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target and 'parent.relativePath' points at wrong local POM
项目POM文件
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <!-- Project from https://start.vaadin.com/ --> <groupId>com.example.application</groupId> <artifactId>mytodo</artifactId> <name>mytodo</name> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <properties> <java.version>17</java.version> <vaadin.version>24.1.2</vaadin.version> <selenium.version>4.10.0</selenium.version> </properties> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>3.1.0</version> </parent> <repositories> <repository> <id>Vaadin Directory</id> <url>https://maven.vaadin.com/vaadin-addons</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <dependencyManagement> <dependencies> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-bom</artifactId> <version>${vaadin.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>com.vaadin</groupId> <!-- Replace artifactId with vaadin-core to use only free components --> <artifactId>vaadin</artifactId> </dependency> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.parttio</groupId> <artifactId>line-awesome</artifactId> <version>1.1.0</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-testbench-junit5</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <defaultGoal>spring-boot:run</defaultGoal> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <jvmArguments>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5600</jvmArguments> <wait>500</wait> <maxAttempts>240</maxAttempts> </configuration> </plugin> <plugin> <groupId>com.vaadin</groupId> <artifactId>vaadin-maven-plugin</artifactId> <version>${vaadin.version}</version> <executions> <execution> <goals> <goal>prepare-frontend</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <profiles> <profile> <!-- Production mode is activated using -Pproduction --> <id>production</id> <dependencies> <!-- Exclude development dependencies from production --> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-core</artifactId> <exclusions> <exclusion> <groupId>com.vaadin</groupId> <artifactId>vaadin-dev</artifactId> </exclusion> </exclusions> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>com.vaadin</groupId> <artifactId>vaadin-maven-plugin</artifactId> <version>${vaadin.version}</version> <executions> <execution> <goals> <goal>build-frontend</goal> </goals> <phase>compile</phase> </execution> </executions> </plugin> </plugins> </build> </profile> <profile> <id>it</id> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <id>start-spring-boot</id> <phase>pre-integration-test</phase> <goals> <goal>start</goal> </goals> </execution> <execution> <id>stop-spring-boot</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> </executions> </plugin> <!-- Runs the integration tests (*IT) after the server is started --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <executions> <execution> <goals> <goal>integration-test</goal> <goal>verify</goal> </goals> </execution> </executions> <configuration> <trimStackTrace>false</trimStackTrace> <enableAssertions>true</enableAssertions> </configuration> </plugin> </plugins> </build> </profile> </profiles> </project>
环境信息
- Java版本:jdk-17.0.2-windows
- Vaadin版本:24+,23.3.15也存在相同问题
排查方案
1. 清除Maven缓存并强制更新
- 删除本地仓库中失败的依赖目录,例如:
C:\Users\[你的用户名]\.m2\repository\org\springframework\boot\spring-boot-starter-parent\3.1.0 - 执行命令强制Maven更新依赖:
mvn clean install -U
2. 导入SSL证书到JDK信任库
- 访问
https://maven.vaadin.com和https://repo.maven.apache.org,导出网站的SSL证书(格式选.cer) - 以管理员身份打开命令行,执行导入命令(替换路径为你的JDK安装目录和证书路径):
keytool -import -alias vaadin-maven -file D:\cert\vaadin-maven.cer -keystore "C:\Program Files\Java\jdk-17.0.2\lib\security\cacerts" - 输入默认密码
changeit,确认导入证书
3. 调整POM仓库配置
- 在POM的
<repositories>节点中添加Maven中央仓库,优先从中央仓库拉取Spring Boot依赖:<repositories> <repository> <id>central</id> <url>https://repo.maven.apache.org/maven2</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>Vaadin Directory</id> <url>https://maven.vaadin.com/vaadin-addons</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories>
4. 手动修复XML Schema文件
- 手动下载
http://maven.apache.org/xsd/maven-4.0.0.xsd文件 - 将文件放到目录
%USERPROFILE%\.lemminx\cache\http\maven.apache.org\xsd\下,确保文件名是maven-4.0.0.xsd
5. 检查系统代理与防火墙
- 关闭系统代理设置,重新尝试构建
- 确认公司防火墙未拦截Maven仓库的HTTPS请求,如有内部Maven镜像,切换为内部镜像地址
内容的提问来源于stack exchange,提问作者Liemannen loop
相关产品推荐
相关产品推荐

