【问题标题】:Maven, how to access class from an other artifactMaven,如何从其他工件访问类
【发布时间】:2012-01-26 10:59:04
【问题描述】:

我制作了 3 个工件 常见的 配置 和完整的 在我的完整 pom 中,我有:

        <dependency>
            <groupId>fr</groupId>
            <artifactId>Common</artifactId>
            <version>1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>fr</groupId>
            <artifactId>pConfig</artifactId>
            <version>1</version>
            <scope>compile</scope>
        </dependency>

在我的完整工件代码源中,我尝试访问 Config 类,但它不起作用。 Maven 安装工作,但我在 Eclipse 中有一个错误: 导入 fr.datacontrol.DataSources;我有:无法解决导入... 你有想法吗? 谢谢

【问题讨论】:

  • 您在 Common 和 Config 项目中运行过mvn install 吗? Config 和 Common 项目是否出现在 Eclipse 项目的 Maven Dependencies 下? (另外,pConfig artifactId 看起来像是一个错字。)

标签: maven import dependencies artifact


【解决方案1】:

如果它在 Maven 中工作但在 Eclipse 中不工作,这意味着您在 Eclipse 中的构建路径与在 Maven 中的构建路径不同。这可能意味着 Eclipse 在构建项目时没有使用 POM 中的信息。

您可能需要在 Eclipse 中安装 m2e 插件——尽管我认为从 Indigo 开始默认包含它。

或者您可能只需要告诉 Eclipse 它是一个 Maven 项目:右键单击项目 -> 配置 -> 转换为 Maven 项目(在 Indigo 中)

【讨论】:

    猜你喜欢
    • 2014-10-06
    • 2013-03-21
    • 1970-01-01
    • 1970-01-01
    • 2018-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多