首先,我想通知这里有同样的问题 grails plugin dependencies with classifiers但他们没有答案。
我正在尝试将jar“json-lib.jar”及其依赖项添加到BuildConfig.groovy文件中。这个依赖项有一个被调用的元素,因为我无法下载依赖项。
dependencies {runtime group:'net.sf.json-lib', name:'json-lib', classifier:'jdk15',version:'2.4'}
但这没有用。
我也试过这个
`dependencies {runtime'net.sf.json-lib:json-lib:2.4:jdk15'}
这个也没有帮助
甚至尝试创建一个maven pom文件并将“json-lib.jar”依赖项添加到pom文件中但得到相同但是如果尝试在我的java maven项目中使用相同的依赖项它可以正常工作
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<type>jar</type>
<classifier>jdk15</classifier>
<scope>compile</scope>
</dependency>
但是这个也没有帮助。
我尝试刷新依赖项的错误消息(在STS中)
WARNINGS
[FAILED ] net.sf.json-lib#json-lib;2.4!json-lib.jar: (0ms)
==== grailsHome: tried
C:\Users\Target\.grails\2.1.1\cached-installed-plugins/json-lib-2.4.jar
==== grailsHome: tried
C:\Users\Target\Software\Groovy -STS\Installed Directory\grails-2.1.1/plugins/json-lib-2.4.jar
==== grailsCentral: tried
http://grails.org/plugins/grails-json-lib/tags/RELEASE_2.4/grails-json-lib-2.4.jar
==== http://repo.grails.org/grails/core: tried
http://repo.grails.org/grails/core/net/sf/json-lib/json-lib/2.4/json-lib-2.4.jar
==== localMavenResolver: tried
C:\Users\Target/.m2/repository/net/sf/json-lib/json-lib/2.4/json-lib-2.4.jar
==== mavenCentral: tried
http://repo1.maven.org/maven2/net/sf/json-lib/json-lib/2.4/json-lib-2.4.jar
==== ebrRelease: tried
http://repository.springsource.com/maven/bundles/release/net/sf/json-lib/json-lib/2.4/json-lib-2.4.jar
==== ebrExternal: tried
http://repository.springsource.com/maven/bundles/external/net/sf/json-lib/json-lib/2.4/json-lib-2.4.jar
==== http://download.java.net/maven/2/: tried
http://download.java.net/maven/2/net/sf/json-lib/json-lib/2.4/json-lib-2.4.jar
==== localMavenResolver: tried
C:\Users\Target/.m2/repository/net/sf/json-lib/json-lib/2.4/json-lib-2.4.jar
::::::::::::::::::::::::::::::::::::::::::::::
:: FAILED DOWNLOADS ::
:: ^ see resolution messages for details ^ ::
::::::::::::::::::::::::::::::::::::::::::::::
:: net.sf.json-lib#json-lib;2.4!json-lib.jar
::::::::::::::::::::::::::::::::::::::::::::::
:: problems summary ::
:::: WARNINGS
[FAILED ] net.sf.json-lib#json-lib;2.4!json-lib.jar: (0ms)
==== grailsHome: tried
C:\Users\Target\Software\Groovy -STS\Installed Directory\grails-2.1.1/lib/net.sf.json-lib/json-lib/jars/json-lib-2.4.jar
C:\Users\Target\Software\Groovy -STS\Installed Directory\grails-2.1.1/lib/net.sf.json-lib/json-lib/bundles/json-lib-2.4.jar
==== grailsHome: tried
C:\Users\Target\Software\Groovy -STS\Installed Directory\grails-2.1.1\src\libs/json-lib-2.4.jar
==== grailsHome: tried
C:\Users\Target\Software\Groovy -STS\Installed Directory\grails-2.1.1\dist/json-lib-2.4.jar
==== grailsHome: tried
C:\Users\Target\.grails\2.1.1\cached-installed-plugins/json-lib-2.4.jar
==== grailsHome: tried
C:\Users\Target\Software\Groovy -STS\Installed Directory\grails-2.1.1/plugins/json-lib-2.4.jar
==== grailsCentral: tried
http://grails.org/plugins/grails-json-lib/tags/RELEASE_2.4/grails-json-lib-2.4.jar
==== http://repo.grails.org/grails/core: tried
http://repo.grails.org/grails/core/net/sf/json-lib/json-lib/2.4/json-lib-2.4.jar
==== localMavenResolver: tried
C:\Users\Target/.m2/repository/net/sf/json-lib/json-lib/2.4/json-lib-2.4.jar
==== mavenCentral: tried
http://repo1.maven.org/maven2/net/sf/json-lib/json-lib/2.4/json-lib-2.4.jar
==== ebrRelease: tried
http://repository.springsource.com/maven/bundles/release/net/sf/json-lib/json-lib/2.4/json-lib-2.4.jar
==== ebrExternal: tried
http://repository.springsource.com/maven/bundles/external/net/sf/json-lib/json-lib/2.4/json-lib-2.4.jar
==== http://download.java.net/maven/2/: tried
http://download.java.net/maven/2/net/sf/json-lib/json-lib/2.4/json-lib-2.4.jar
==== localMavenResolver: tried
C:\Users\Target/.m2/repository/net/sf/json-lib/json-lib/2.4/json-lib-2.4.jar
::::::::::::::::::::::::::::::::::::::::::::::
:: FAILED DOWNLOADS ::
:: ^ see resolution messages for details ^ ::
::::::::::::::::::::::::::::::::::::::::::::::
:: net.sf.json-lib#json-lib;2.4!json-lib.jar
::::::::::::::::::::::::::::::::::::::::::::::
| Error Failed to resolve dependencies (Set log level to 'warn' in BuildConfig.groovy for more information):
- net.sf.json-lib:json-lib:2.4
提前致谢..
答案 0 :(得分:0)
以下内容应该有效,请参阅此处:http://mvnrepository.com/artifact/net.sf.json-lib/json-lib/2.4#gradle
dependencies {
runtime 'net.sf.json-lib:json-lib:2.4'
}
另外,请检查您是否启用了MavenLocal和MavenCentral存储库:
repositories {
grailsPlugins()
grailsHome()
grailsCentral()
// uncomment the below to enable remote dependency resolution
// from public Maven repositories
mavenLocal()
mavenCentral()
//mavenRepo "http://snapshots.repository.codehaus.org"
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}