sga*_*gel 14 java spring gradle jenkins
我在Jenkins上运行gradle构建时遇到问题:Gradle版本是https://services.gradle.org/distributions/gradle-2.14.1-bin.zip
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'myApp'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:1.4.2.RELEASE.
Required by:
:myApp:unspecified
> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:1.4.2.RELEASE.
> Could not get resource 'https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-gradle-plugin/1.4.2.RELEASE/spring-boot-gradle-plugin-1.4.2.RELEASE.pom'.
> Could not HEAD 'https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-gradle-plugin/1.4.2.RELEASE/spring-boot-gradle-plugin-1.4.2.RELEASE.pom'.
> repo1.maven.org: Nome o servizio sconosciuto
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
这是我的build.gradle文件:
buildscript {
ext {
springBootVersion = '1.4.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'
war {
baseName = 'myApp'
version = '1.0.5'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
configurations {
providedRuntime
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
compile('org.springframework.boot:spring-boot-starter-security')
testCompile('org.springframework.boot:spring-boot-starter-test')
compile('org.springframework.boot:spring-boot-starter-web')
compile('com.fasterxml.jackson.core:jackson-core:2.7.3')
compile("org.springframework:spring-jdbc")
compile('com.fasterxml.jackson.core:jackson-databind:2.7.3')
compile('com.fasterxml.jackson.core:jackson-annotations:2.7.3')
compile files('src/main/resources/static/lib/ojdbc7.jar')
// https://mvnrepository.com/artifact/org.json/json
compile group: 'org.json', name: 'json', version: '20080701'
}
Run Code Online (Sandbox Code Playgroud)
由于错误告诉您Nome o servizio sconosciuto,repo1.maven.org无法通过DNS解决.因此,您遇到了一些网络问题,或者您需要使用未配置Gradle的代理服务器.询问您的IT支持,了解无法解析主机名的原因.
小智 7
当我尝试使用 gradle 3.5 使用我的笔记本电脑(无需代理)首次在 IntelliJ 上运行 gradle 时,出现了 spring-boot-starter 依赖项无法解决的问题。
问题被遗漏了:
apply plugin: 'org.springframework.boot'
Run Code Online (Sandbox Code Playgroud)
来自 build.gradle 文件。一旦包含,它就会立即下载所有依赖项。
小智 6
这可能是网络问题。如果没有,请尝试以下步骤,因为它解决了我的问题。
由于我也面临同样的问题,我尝试通过更改依赖项来解决它。
这个值给了我一个错误。
compile("org.springframework.boot:spring-boot-starter-ws")
Run Code Online (Sandbox Code Playgroud)
这是有效的
compile group: 'org.springframework.boot', name: 'spring-boot-starter-ws', version: '1.4.7.RELEASE'
Run Code Online (Sandbox Code Playgroud)
参考:https : //mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-ws/1.1.8.RELEASE