在Maven项目的模块内共享类 [英] Share classes within modules in maven project
问题描述
首先,我是maven的新手,对于这个问题是否太简单,我们深感抱歉:)
firstly I'm new to maven , so sorry for the question if it's too simple :)
我有主模块"main" 和子模块:a,b,c,...
I have main module "main" and child modules : a , b , c , ...
我想要与子模块b共享子模块a中的一些数据.
What I want is to share some data which is in child module a , with child module b.
父pom看起来像: 4.0.0
The parent pom looks like : 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>
我要分享的孩子看起来像:
The child I want to share looks like :
<parent>
<artifactId>Parent</artifactId>
<groupId>Parent</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>a</artifactId>
</project>
和消费者"孩子看起来像:
and "consumer" child looks like :
<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文件夹,没有代码(可以吗?)
I do see the jar file being added to the "External Library" (I'm using Intellij) But the jar contains only META-INF folder without the code (is it ok ?)
故事的结尾,我不能在ChildB类中使用ChildA类... 任何需要帮助的人!!
End of story, I cannot use Class ChildA in ChildB classes ... Any help whould be appriciated !!
推荐答案
问题是我已经弄乱了" maven的项目结构.... 一旦构建了应由maven进行的模块,就可以像一个魅力一样工作了:) http://maven.apache.org/guides /introduction/introduction-to-the-standard-directory-layout.html
The problem was that I've "btoken" maven's project stracture .... Once I've build the module as it should be by maven , works like a charm :) http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
这篇关于在Maven项目的模块内共享类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!