这是我的构建文件。我使用的是Intellij CE。我试图使用this yahoo finance 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
我做错了什么?
答案 0 :(得分:2)
4.0
Maven中不存在YahooFinanceAPI。最新的一个是3.5.0
- cf - https://mvnrepository.com/artifact/com.yahoofinance-api/YahooFinanceAPI
通过修改版本并添加用于创建胖罐的选项
进行测试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" )
}
}
Ran 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