Thingsboard PKIX path building failed:异常

戏子无情 提交于 2020-08-08 19:06:08

Thingsboard最让人头疼的就是项目的编译问题,其中在编译Thingsboard HTTP模块时我遇到的问题是:PKIX path building failed

 

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'http'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not download gradle-ospackage-plugin.jar (com.netflix.nebula:gradle-ospackage-plugin:3.8.0)
      > Could not get resource 'https://jcenter.bintray.com/com/netflix/nebula/gradle-ospackage-plugin/3.8.0/gradle-ospackage-plugin-3.8.0.jar'.
         > Could not GET 'https://jcenter.bintray.com/com/netflix/nebula/gradle-ospackage-plugin/3.8.0/gradle-ospackage-plugin-3.8.0.jar'.
            > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 8.864 secs
[INFO] Initialize build
[INFO] Build
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  10.707 s
[INFO] Finished at: 2020-05-19T11:12:44+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.fortasoft:gradle-maven-plugin:1.0.8:invoke (default) on project http: org.gradle.tooling.BuildException: Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.13-bin.zip'. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

尝试了很多关于maven PKIX path building failed的解决办法,包括参考:

忽略证书校验

https://blog.csdn.net/qq157538651/article/details/95811622

https://my.oschina.net/ghw/blog/3236131/print

配置证书

https://blog.csdn.net/i_like1/article/details/80334298

https://www.cnblogs.com/zdz8207/p/java-https-ssl-jsoup.html

以上无法都对我无效。。。。。

百般无奈只能从地址下手,找出https://jcenter.bintray.com的源头,是项目中gradle配置的默认仓库,将仓库修改为阿里的非https地址,到此问题解决。

找到Thingsboard项目/transport/http/build.gradle文件中的:

repositories {
    jcenter()
}

修改为:

repositories {
    maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'}
    jcenter()
}

为了避免其他模块再出现相同问题,索性将所有的build.gradle全部修改一遍。

也可以一次性解决所有问题, 如果想一次更改所有的仓库地址,可以在 USER_HOME/.gradle/文件夹下添加 init.gradle 文件来配置,如:

allprojects {
    repositories {
		maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven { url 'http://maven.aliyun.com/repository/public/' }
        maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
        maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}

        all { ArtifactRepository repo ->
            if (repo instanceof MavenArtifactRepository) {
                def url = repo.url.toString()

                if (url.startsWith('https://repo.maven.apache.org/maven2/') || url.startsWith('https://repo.maven.org/maven2') || url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')) {
                    //project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
                    remove repo
                }
            }
        }
    }

    buildscript {

        repositories {
			maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
            maven { url 'http://maven.aliyun.com/repository/public/'}
            maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
            maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
            all { ArtifactRepository repo ->
                if (repo instanceof MavenArtifactRepository) {
                    def url = repo.url.toString()
                    if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')) {
                        //project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
                        remove repo
                    }
                }
            }
        }
    }

}

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!