gpt4 book ai didi

java - 无法使用 gradle 安装库

转载 作者:行者123 更新时间:2023-12-02 03:16:21 26 4
gpt4 key购买 nike

这是我的构建文件。我正在使用 Intellij CE。我正在尝试使用this雅虎财经 API:

group 'com.scrap'
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.5

repositories {
mavenCentral()
}

dependencies {
compile group: 'com.yahoofinance-api', name: 'YahooFinanceAPI', version: '4.0.0'
compile 'joda-time:joda-time:2.2'
testCompile group: 'junit', name: 'junit', version: '4.11'
}

当我在 Gradle 工具窗口中手动同步项目时,我在 yahoofinance 库下方看到一条红线,并显示一条消息

unable to resolve com.yahoofinance-api:YahooFinanceAPI:4.0.0

我做错了什么?

最佳答案

4.0 YahooFinanceAPI 在 Maven 中不存在。最新的是3.5.0 - cf - https://mvnrepository.com/artifact/com.yahoofinance-api/YahooFinanceAPI

通过修改版本并添加创建 fat jar 的选项进行测试

group 'com.scrap'
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.5

repositories {
mavenCentral()
}

dependencies {
compile group: 'com.yahoofinance-api', name: 'YahooFinanceAPI', version: '3.5.0' //Changed version
compile 'joda-time:joda-time:2.2'
testCompile group: 'junit', name: 'junit', version: '4.11'
}

// Added new section
jar {
from {
(configurations.runtime).collect {
it.isDirectory() ? it : zipTree(it)
}
}
manifest {
attributes("Main-Class": "Main" )
}
}

运行gradle clean build并下载依赖项

$ gradle clean build
Download https://repo1.maven.org/maven2/com/yahoofinance-api/YahooFinanceAPI/3.5.0/YahooFinanceAPI-3.5.0.pom
Download https://repo1.maven.org/maven2/com/yahoofinance-api/YahooFinanceAPI/3.5.0/YahooFinanceAPI-3.5.0.jar
Download https://repo1.maven.org/maven2/joda-time/joda-time/2.2/joda-time-2.2.jar
:clean
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build

BUILD SUCCESSFUL

Total time: 10.199 secs

关于java - 无法使用 gradle 安装库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40231763/

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