gpt4 book ai didi

spring - Gradlew 构建不起作用

转载 作者:行者123 更新时间:2023-12-03 05:14:00 28 4
gpt4 key购买 nike

当我尝试使用 ./gradlew clean 清理我的项目时它有效,但是./gradlew build不会工作。我尝试了一些存储库,但它无法解决 Spring 依赖项。

这里是 build.gradle :

apply plugin: 'war'

war {
baseName = 'hello'
}

configurations {
providedRuntime
}

dependencies {

compile('org.springframework.boot:spring-boot-starter-web')
compile('org.json:json:20141113')
compile('com.jayway.jsonpath:json-path:0.8.1')
compile('org.jsoup:jsoup:1.8.2')
compile('org.springframework.social:spring-social-twitter')
compile('org.springframework.social:spring-social-twitter:1.1.0.RELEASE')
compile('org.springframework.social:spring-social-core')
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
testCompile('org.springframework.boot:spring-boot-starter-test')
}

repositories {
mavenCentral()
}

这里有一个异常(exception):
* What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> Cannot resolve external dependency org.springframework.boot:spring-boot-starter-web: because no repositories are defined.
Required by:
:hello:unspecified
> Cannot resolve external dependency org.json:json:20141113 because no repositories are defined.
Required by:
:hello:unspecified
> Cannot resolve external dependency com.jayway.jsonpath:json-path:0.8.1 because no repositories are defined.
Required by:
:hello:unspecified
> Cannot resolve external dependency org.jsoup:jsoup:1.8.2 because no repositories are defined.
Required by:
:hello:unspecified
> Cannot resolve external dependency org.springframework.social:spring-social-twitter:1.1.0.RELEASE because no repositories are defined.
Required by:
:hello:unspecified
> Cannot resolve external dependency org.springframework.social:spring-social-twitter:1.1.0.RELEASE because no repositories are defined.
Required by:
:hello:unspecified
> Cannot resolve external dependency org.springframework.social:spring-social-core: because no repositories are defined.
Required by:
:hello:unspecified

我认为 maven repo 就足够了,但它一直失败我也尝试过 jcenter() .我正在使用 ubuntu 14.04 虚拟机。

已解决:

正如迈克尔在评论中所说,我必须为依赖项添加一个版本:
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-web:1.3.3.RELEASE')

最佳答案

首先,在依赖项之前声明存储库。其次,更换

compile('org.springframework.boot:spring-boot-starter-web')


compile('org.springframework.boot:spring-boot-starter-web:1.3.3.RELEASE')

因为前者不包含版本。

关于spring - Gradlew 构建不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36618654/

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