我准备在Intellij Idea中建立一个新的Gradle项目,但我在加载依赖关系时总是失败,这是我的Gradle文件,如果我执行这个Gradle脚本,就会出现 "无法解析com.google.gwt:gwt:2.9.0 "的错误。
plugins {
id 'java'
}
group 'ch.demo'
version '7.4.5.0'
repositories {
mavenCentral()
}
dependencies {
compile group: 'com.google.gwt', name: 'gwt', version: '2.9.0'
}
如果我执行这个gradle脚本,我得到的错误是 "Could not resolve com.google.gwt:gwt:2.9.0."。
maven模块应该是正确的,它在这里可以找到。https:/repo.maven.apache.orgmaven2comgooglegwtgwt2.9.0。
似乎我做错了什么。有人知道如何解决这个问题吗?
也试过 compile 'com.google.gwt:gwt:2.9.0'
但这也没有用。
编辑。
我使用了 "重新导入所有Gradle项目 "的命令,到目前为止。如果我按 "执行Gradle任务"-> "gradle构建",我得到以下错误。
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
> Could not resolve com.google.gwt:gwt:2.9.0.
Required by:
project :
> Could not resolve com.google.gwt:gwt:2.9.0.
> Could not get resource 'https://repo.maven.apache.org/maven2/com/google/gwt/gwt/2.9.0/gwt-2.9.0.pom'.
> Could not GET 'https://repo.maven.apache.org/maven2/com/google/gwt/gwt/2.9.0/gwt-2.9.0.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
像这样试试。
dependencies {
implementation 'com.google.gwt:gwt:2.9.0'
}
建议使用实现而不是编译。关于这一点可以在这里找到进一步的说明。
更新。我刚刚在我的机器上试了一下,效果不错。
plugins { id 'java' } group 'org.example' version '1.0-SNAPSHOT' repositories { mavenCentral() } dependencies { implementation 'com.google.gwt:gwt:2.9.0' }
演示一下我是如何创建项目的,终端上显示构建已通过。