java-如何使用不同的分类器在常春藤中下载多个Maven依赖项?

我试图依靠常春藤的Neo4j server jarNeo4j server jar – static-web.jar.我正在尝试类似

<ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven">
<info organisation="org.jimwebber" module="neo4j-koans"/>
<dependencies>
    <dependency org="org.springframework.data" name="spring-data-neo4j" rev="1.0.0.RELEASE">
        <exclude module="jms"/>
        <exclude module="jmxtools"/>
        <exclude module="jmxri"/>
        <exclude org="org.slf4j" name="slf4j-log4j12"/>
    </dependency>
    <dependency org="org.aspectj" name="aspectjrt" rev="1.6.11.RELEASE"/>
    <dependency org="org.aspectj" name="aspectjtools" rev="1.6.11.RELEASE"/>
    <dependency org="org.neo4j.app" name="neo4j-server" rev="1.5-SNAPSHOT" m:classifier="static-web"/>
    <dependency org="org.neo4j.app" name="neo4j-server" rev="1.5-SNAPSHOT"/>
    <dependency org="org.neo4j" name="neo4j-community" rev="1.5-SNAPSHOT"/>
    <dependency org="org.neo4j" name="neo4j-shell" rev="1.5-SNAPSHOT"/>
    <dependency org="org.codehaus.jackson" name="jackson-core-asl" rev="1.7.5"/>
    <dependency org="org.codehaus.jackson" name="jackson-mapper-asl" rev="1.7.5"/>
    <dependency org="com.sun.jersey" name="jersey-client" rev="1.3"/>
    <dependency org="org.mockito" name="mockito-all" rev="1.8.5"/>
    <dependency org="junit" name="junit" rev="4.7"/>        
</dependencies>
</ivy-module>

但是我从来没有下载过“ staic-web” .jar,现在也出错了.有人知道该怎么做吗?

感谢您的提示!

/彼得

解决方法:

这是您检索与Maven模块关联的多个工件的方式:

<dependency org="org.neo4j.app" name="neo4j-server" rev="1.5-SNAPSHOT">
    <artifact name="neo4j-server" type="jar" />
    <artifact name="neo4j-server" type="jar" m:classifier="static-web"/>
</dependency>

由于Maven使用分类器引用其他工件的方式,因此语法很奇怪.

需要将neo4j快照存储库添加到ivysettings.xml文件中(快照发行版不会发布到Maven Central)

<ivysettings>
    <settings defaultResolver="chain"/>
    <resolvers>
        <chain name="chain">
            <ibiblio name="central" m2compatible="true"/>
            <ibiblio name="neo4j-snapshot" m2compatible="true" root="http://repo.neo4j.org/content/repositories/snapshots"/>
        </chain>
    </resolvers>
</ivysettings>

其他事宜

版本更正

<dependency org="org.aspectj" name="aspectjrt" rev="1.6.11"/>
<dependency org="org.aspectj" name="aspectjtools" rev="1.6.11"/>

存储库POM损坏

使用快照存储库的问题有时是POM损坏了.常春藤无法处理以下文件:

http://repo.neo4j.org/content/repositories/snapshots/org/neo4j/app/neo4j-server/1.5-SNAPSHOT/neo4j-server-1.5-SNAPSHOT.pom

这样可以防止常春藤下载neo4j-server arifacts….

[ivy:retrieve] :::: WARNINGS
[ivy:retrieve]  io problem while parsing ivy file: http://repo.neo4j.org/content/repositories/snapshots/org/neo4j/app/neo4j-server/1.5-SNAPSHOT/neo4j-server-1.5-SNAPSHOT.pom: Impossible to load parent for file:/home/mark/.ivy2/cache/org.neo4j.app/neo4j-server/ivy-1.5-SNAPSHOT.xml.original. Parent=org.neo4j.build#parent-pom;25
[ivy:retrieve]      module not found: org.neo4j.app#neo4j-server;1.5-SNAPSHOT
..
[ivy:retrieve]      ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]      ::          UNRESOLVED DEPENDENCIES         ::
[ivy:retrieve]      ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]      :: org.neo4j.app#neo4j-server;1.5-SNAPSHOT: not found
[ivy:retrieve]      ::::::::::::::::::::::::::::::::::::::::::::::

变通

在设置文件中,将ivy配置为使用url resolver直接检索工件.ibiblio resolver用于其POM有效的所有其他模块.

<ivysettings>
    <settings defaultResolver="chain"/>
    <resolvers>
        <chain name="chain">
            <ibiblio name="central" m2compatible="true"/>
            <ibiblio name="neo4j-snapshot" m2compatible="true" root="http://repo.neo4j.org/content/repositories/snapshots"/>
        </chain>
        <url name="neo4j-snapshot-hack">
              <artifact pattern="http://repo.neo4j.org/content/repositories/snapshots/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"/>
        </url>
    </resolvers>
    <modules>
        <module organisation="org.neo4j.app" name="neo4j-server" resolver="neo4j-snapshot-hack"/>
    </modules>
</ivysettings>

这意味着跳过的POM文件中的传递依赖关系可能会被跳过.如果POM工作不正常,将无法解决

上一篇:java – 最佳常春藤实践:将代码拆分为多个项目或使用一个具有多个配置的项目?


下一篇:java-为什么ivyde看不到我的依赖项之一?