gpt4 book ai didi

java - gradle 构建访问被拒绝

转载 作者:行者123 更新时间:2023-12-02 10:16:20 24 4
gpt4 key购买 nike

嗨,我是 gradle、java 和 IJ idea 的新手。我正在尝试使用 gradle 构建一些 java 项目。当我运行命令时:

C:\Users\xxx\IdeaProjects\example2>gradle build

构建失败。

   FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileTestJava'.
> Could not resolve all files for configuration ':testCompileClasspath'.
> Could not resolve org.testng:testng:6.14.3.
Required by:
project :
> Could not resolve org.testng:testng:6.14.3.
> Could not get resource 'https://repo.maven.apache.org/maven2/org/testng/testng/6.14.3/testng-6.14.3.pom'.
> Could not GET 'https://repo.maven.apache.org/maven2/org/testng/testng/6.14.3/testng-6.14.3.pom'.
> Received fatal alert: access_denied

文件夹 IdeaProjects/example2 可供所有用户完全访问。当我使用 --stacktrace 选项运行命令时,最后一个“引起的”是:

            ... 106 more
Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: access_denied
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:396)

是否是 SSL 证书有问题?我正在使用代理连接到网络。

这是我正在使用的 build.gradle 文件

plugins {
id 'java'
id 'idea'
}

group 'jetbrains'
version '1.0'

sourceCompatibility = 1.8

repositories {
mavenCentral()
}

dependencies {
//testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.testng', name: 'testng', version: '6.14.3'
// https://mvnrepository.com/artifact/io.rest-assured/rest-assured
//compile group: 'io.rest-assured', name: 'rest-assured', version: '3.1.0'
//testCompile group: 'io.rest-assured', name: 'rest-assured', version: '3.1.0'
}

最佳答案

问题已解决,感谢stackoverflow.com/a/22666646/2987755 。必须在 gradle.properties 文件中设置以下变量/属性。

systemProp.http.proxyHost=$proxy
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=$proxy
systemProp.https.proxyPort=8080

关于java - gradle 构建访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54651380/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com