java - gradle 构建访问被拒绝
问题描述
嗨,我是 gradle 和 java 和 IJ 想法的新手。我正在尝试使用 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
推荐阅读
- c# - 如何检查输出 DbParameter 的空值?
- react-native - 在 React Native 中从上到下并排动画视图
- amazon-web-services - 如何从给定的 AWS Powershell cmdlet/别名中检索所有数据?
- javascript - Nest.Js 从一个控制器重定向到另一个
- sql - 如果在特定时间后记录工作,则将目标时间添加到下一个工作日
- sql - Sql存储过程计算经纪人的股权周转率
- c++ - 如何在不保存/加载文件的情况下从 ID3D11Texture2D 创建 PNG 格式的字节数组?
- python - 套接字块/缓冲区大小
- python-3.x - 在 pandas 中调用 df.X 时返回非 NaN 值
- .net - 从正在运行的 Visual Studio 实例打开 vstfs url