how to fix configuration not found in guava error

不羁的心 提交于 2019-12-04 06:15:25

问题


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>

回答1:


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:

  • IVY Build, how do I use an extlib directory in the project?
  • Ivy dependency management for legacy repository

Hope this helps.




回答2:


I was sure my ivy configuration was right and I still kept getting the error. I am not sure how but my IVY cache was messed up. Clearing the cache (I used rm -rf) and running the build again do it.



来源:https://stackoverflow.com/questions/25505746/how-to-fix-configuration-not-found-in-guava-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!