如何修复在番石榴错误中找不到的配置 [英] how to fix configuration not found in guava error

查看:33
本文介绍了如何修复在番石榴错误中找不到的配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图解决本地文件系统的依赖关系;为此,我编写了ivy.xml、ivyconf.xml 和build.xml.但是,我的脚本不起作用并且无法解析依赖项,即找不到 jar 文件.背后的问题是什么?还有,我该如何解决?

I have tried to resolve dependencies from local filesystem; to do so, I have wrote ivy.xml, ivyconf.xml and build.xml. However, my scripts donot work and couldnot resolve dependencies i.e. couldnot find jar files. What is the problem behind it? And, how can I solve it?

错误

Error
[ivy:resolve] com.google.guava#guava;17.0: configuration not found in
              com.google.guava#guava;17.0: 'public'. It was required from 
              .. runtime

项目层次结构

project
  | - - src
  | - - lib
         | - - guava.jar
  | - - conf
         | - - ant
                | - - build.xml
         | - - ivy
                | - - ivy.xml
                | - - ivyconf.xml

ivy.xml 文件

<ivy-module version="2.0">
    <configurations defaultconfmapping="runtime->public">
        <conf   name="compile"      visibility="private"/>
        <conf   name="jar"
                extends="compile"       
                visibility="private"/>

        <conf   name="runtime"      
                extends="jar"   
                visibility="public"/>
    </configurations>

    <dependencies>
        <dependency org="com.google.guava"  name="guava"    rev="17.0"  conf="runtime->public"/>
    </dependencies>
</ivy-module>

最后,ivyconf.xml

lastly, ivyconf.xml

<conf   defaultresolver="local"/>
<resolves>
        <filesystem name="local">
            <artifact   pattern="${lib.dir}/**/*.jar" />
        </filesystem>
</resolves>

推荐答案

您的 ivy 配置文件无效(resolvers"而不是resolves").此外,如果 jar 文件的文件名中不包含版本,那么您将遇到依赖版本控制问题.

Your ivy configuration file is invalid ("resolvers" not "resolves"). Additionally you're going to have problems with dependency versioning if the jar file does not contain a version in the filename.

我的建议是使用下面的ivy配置文件:

My suggestion is to use the following ivy configuration file:

<ivysettings>
  <settings defaultResolver='central' />
  <resolvers>
    <ibiblio name='central' m2compatible='true'/>
    <filesystem name='local'>
      <artifact pattern='${ivy.settings.dir}/../../lib/[artifact]' />
    </filesystem>
  </resolvers>
  <modules>
    <module organisation='NA' resolver='local' />
  </modules>
</ivysettings>

然后您可以选择如下声明您的依赖项:

You'll then have a choice of declaring your dependencies as follows:

<dependency org="com.google.guava" name="guava" rev="17.0" />

<dependency org="NA"  name="guava" rev="NA"  conf="runtime->default"/>

第一个将从 Maven 中心检索存储库,第二个将从您的本地文件系统中检索.

The first will retrieve from the Maven central repository, the second will retrieve from your local filesystem.

有关此方法的更多示例,请参阅以下答案:

See the following answers for more examples of this approach:

希望这会有所帮助.

这篇关于如何修复在番石榴错误中找不到的配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆