且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何解决配置番石榴错误未找到

更新时间:2022-10-16 09:43:10

您常青藤配置文件是无效的(解析器而不是做出决议)。此外你将有依赖版本问题如果JAR文件不包含在文件名的版本。

我的建议是使用下面的常青藤配置文件:

 < ivysettings>
  <设置defaultResolver ='中间'/>
  <&解析器GT;
    < ibiblio上的名字='中间'm2compatible =真/>
    <文件系统的名称=本地>
      <神器模式='$ {} ivy.settings.dir LIB /../../ / [神器]/>
    < /文件系统>
  < /解析器>
  <模块>
    <模块组织=NA解析=本地/>
  < /模块>
< / ivysettings>

您会然后让你声明依赖的选择如下:

 <依赖有机=com.google.guavaNAME =番石榴REV =17.0/><依赖有机=NANAME =番石榴REV =NA的conf =runtime->默认/>

第一个将检索来自 Maven的中间储存库,第二个将检索您的本地文件系统。

请参阅此方法的更多示例如下回答:

希望这有助于。

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

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 hierarchy

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

ivy.xml file

<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>

lastly, ivyconf.xml

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

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.

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"/>

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:

Hope this helps.