Multimodule Maven project in Intellij

2019-05-20 04:42发布

问题:

Issue: For some reason my main application can't import classes from other modules.

Also I don't see the compiled output of Data and Remote modules getting included in main Main:war: exploded under WEB-INF/classes under Module Settings (IntelliJ)

Main application

<groupId>com.example.entitlement</groupId>
<artifactId>service</artifactId>
<version>1.0-SNAPSHOT</version>
<modules>
    <module>Data</module>
    <module>Remote</module>
</modules>
<packaging>pom</packaging>

Data Module

<parent>
    <artifactId>service</artifactId>
    <groupId>com.example.entitlement</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>data</artifactId>

Remote Module

<parent>
    <artifactId>service</artifactId>
    <groupId>com.example.entitlement</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>remote</artifactId>

Edit

I've added dependencies as suggested.

    <dependency>
        <groupId>com.example.entitlement</groupId>
        <artifactId>data</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.example.entitlement</groupId>
        <artifactId>remote</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>

Edit

My directory structure