5

首先,我想告知这里提出了同样的问题 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'}

但这无济于事。

我也试过这样

`依赖{运行时'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

提前致谢..

4

1 回答 1

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/"
}
于 2013-03-16T21:52:51.247 回答