Intellij-idea - module dependency not working in maven multimodal project

Multi Module Maven project configured in Intellij. There are two modules - general and service. the general dependency is added to the pom.xml of the service module. mvn clean install

successful, but Intellij shows compilation error when importing class into shared module into service module class.

I have tried a variety of settings, such as the reimport, the Rebuild, the Synchronize, mvn clean install

, mvn -U idea:idea

. But nobody works.

Finally, it works after manually adding a module's Dependency tab from the Dependencies tab in the Project Navigator window.

How can I configure Intellij to automatically add module dependencies?

Below is the relevant code.

pom.xml of the common module:

<project ...>

<modelVersion>4.0.0</modelVersion>

<name>common</name>
<groupId>myproject</groupId>
<artifactId>common</artifactId>
<version>1.0</version>
<packaging>jar</packaging>

...

      

pom.xml service module

...

<dependencies>
    <dependency>
        <groupId>myproject</groupId>
        <artifactId>common</artifactId>
        <version>1.0</version>
        <type>jar</type>
    </dependency>

...

      

class com.common.Customer common module.

package com.common;

public class Customer {
...
}

      

the com.service.CustManager class of the service module.

package com.service;

import com.common.Customer; // getting error in Itellij at this line.

public class CustManager {
...
}

      

+3


source to share





All Articles