【问题标题】:Dropwizard 0.8.0 Dependency ProblemsDropwizard 0.8.0 依赖问题
【发布时间】:2015-03-09 14:25:35
【问题描述】:

如果我使用Dropwizard核心,有些项目无法通过ivy解决:

unresolved dependency: org.glassfish.hk2#hk2-utils;2.16: not found
unresolved dependency: org.glassfish.hk2#hk2-locator;2.16: not found

我的常春藤依赖项是:

<dependency org="io.dropwizard" name="dropwizard-core" rev="0.8.0" />  
<dependency org="io.dropwizard" name="dropwizard-jersey" rev="0.8.0"   />
<dependency org="org.apache.commons" name="commons-lang3" rev="3.3.2"/>

如果我搜索 hk-utils 或 hk2-locator,那么我找不到想要的 2.16 版本...这是 Drowpizard 0.8.0 的错误吗?

有人知道如何解决这个问题吗?谢谢。

编辑 - 试试这个:

<dependency org="io.dropwizard" name="dropwizard-core" rev="0.8.0">
    <exclude org="org.glassfish.hk2" module="hk2-utils" />
    <exclude org="org.glassfish.hk2" module="hk2-locator" />
</dependency>  
<dependency org="org.glassfish.hk2" name="hk2-utils" rev="2.4.0-b09" />
<dependency org="org.glassfish.hk2" name="hk2-locator" rev="2.4.0-b09" />

更新:在 Dropwizard 0.8.1 中相同 更新:似乎在 Dropwizard 0.8.4 中解决了

【问题讨论】:

  • hk2 应该是 2.3.0-b10 我对 Ivy 一无所知,但是有了 Maven,dropwizard-jersey 将所有这些都拉进来。
  • 我不认为这是 ivy 与 maven 的问题 :-)
  • 就像我说的我对 Ivy 一无所知,我什至不知道它是否像 Maven 那样管理传递依赖。我只是指出,作为传递依赖,如果构建工具处理传递依赖,那么 HK2 应该被拉入,而不必声明它。
  • 设置 transitive="true" 或 false 没有帮助
  • 更正我的评论。我正在测试另一个使用 HK2 2.3.0-b10 的 Jersey 项目,但是只使用 dropwizrd-jersey 创建了一个新项目,我看到 HK2 版本是 2.4.0-b09

标签: jersey ivy dropwizard


【解决方案1】:

为我工作....

也许您应该设置一个“默认”配置映射。

<dependency org="io.dropwizard" ....    conf="default"/>  

示例

以下示例解析依赖关系并为每个 ivy 配置创建报告。

├── build
│   └── ivy-reports
│       ├── com.myspotontheweb-demo-compile.html
│       ├── com.myspotontheweb-demo-runtime.html
│       ├── com.myspotontheweb-demo-test.html
│       └── ivy-report.css
├── build.xml
└── ivy.xml

ivy.xml

<ivy-module version="2.0">
    <info organisation="com.myspotontheweb" module="demo"/>

    <configurations>
        <conf name="compile" description="Required to compile application"/>
        <conf name="runtime" description="Additional run-time dependencies" extends="compile"/>
        <conf name="test"    description="Required for test only" extends="runtime"/>
    </configurations>

    <dependencies>
        <!-- compile dependencies -->
        <dependency org="io.dropwizard" name="dropwizard-core" rev="0.8.0"    conf="compile->default"/>  
        <dependency org="io.dropwizard" name="dropwizard-jersey" rev="0.8.0"  conf="compile->default"/>
        <dependency org="org.apache.commons" name="commons-lang3" rev="3.3.2" conf="compile->default"/>

        <!-- runtime dependencies -->

        <!-- test dependencies -->
    </dependencies>

</ivy-module>

build.xml

<project name="demo" default="resolve" xmlns:ivy="antlib:org.apache.ivy.ant">

    <available classname="org.apache.ivy.Main" property="ivy.installed"/> 

    <target name="install-ivy" description="Install ivy" unless="ivy.installed">
        <mkdir dir="${user.home}/.ant/lib"/>
        <get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.4.0/ivy-2.4.0.jar"/>
        <fail message="Ivy has been installed. Run the build again"/>
    </target>

    <target name="resolve" depends="install-ivy" description="Use ivy to resolve classpaths">
        <ivy:resolve/>

        <ivy:report todir='build/ivy-reports' graph='false' xml='false'/>

        <ivy:cachepath pathid="compile.path" conf="compile"/>
        <ivy:cachepath pathid="test.path"    conf="test"/>
    </target>

    <target name="clean" description="Cleanup build files">
        <delete dir="build"/>
    </target>

    <target name="clean-all" depends="clean" description="Additionally purge ivy cache">
        <ivy:cleancache/>
    </target>

</project>

注意事项:

  • 演示如何生成 ivy 报告和创建配置管理类路径

【讨论】:

  • 我已经使用默认配置了。附加:我使用 Eclipse 和 ApacheIvyDE 并显示此消息。
  • 最后我认为,我必须等待 DW 0.8.1,因为 Dropwizard 使用了损坏的依赖项:-)
猜你喜欢
  • 2015-05-10
  • 1970-01-01
  • 1970-01-01
  • 2012-05-23
  • 1970-01-01
  • 2017-07-12
  • 2020-08-13
  • 2012-12-29
  • 2020-10-21
相关资源
最近更新 更多