【问题标题】:Share classes within modules in maven project在 Maven 项目中的模块内共享类
【发布时间】:2014-12-10 16:27:08
【问题描述】:

首先我是 maven 新手,如果这个问题太简单了,我很抱歉:)

我有主模块“main” 和子模块: a , b , c , ...

我想要的是与子模块 b 共享子模块 a 中的一些数据。

父 pom 看起来像: 4.0.0

    <groupId>Parent</groupId>
    <artifactId>Parent</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>

    <modules>
        <module>a</module>
        <module>b</module>
        <module>c</module>
    </modules>
</project>

我要分享的孩子长这样:

<parent>
    <artifactId>Parent</artifactId>
    <groupId>Parent</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>a</artifactId>
</project>

“消费者”孩子看起来像:

<parent>
        <artifactId>Parent</artifactId>
        <groupId>Parent</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>b</artifactId>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>a</artifactId>
            <version>${project.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
    </dependencies>

我确实看到 jar 文件被添加到“外部库”(我正在使用 Intellij) 但是jar只包含没有代码的META-INF文件夹(可以吗?)

故事结束,我不能在 ChildB 类中使用 Class ChildA ... 任何帮助都应该受到欢迎!

【问题讨论】:

    标签: java maven multi-module


    【解决方案1】:

    问题是我已经“btoken”了maven的项目结构...... 一旦我按照它应该由 maven 构建了模块,它就像一个魅力:) http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html

    【讨论】:

      猜你喜欢
      • 2013-01-21
      • 1970-01-01
      • 2011-09-14
      • 2011-09-14
      • 1970-01-01
      • 2019-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多