Intellij-idea - 模块依赖不在多模块maven项目中工作

Vik*_*rma 5 intellij-idea maven

Multi Module Maven项目在Intellij中配置.有两个模块 - 普通模块和服务模块.在服务模块的pom.xml中添加了公共依赖项.mvn clean install是成功的,仍然Intellij在将公共模块中的类导入到一类服务模块中时显示编译错误.

我尝试了各种选项,例如Reimport,Rebuild,Synchronize mvn clean install, mvn -U idea:idea. 但都没有效果.

最后,它在"项目结构"窗口中手动添加"依赖关系"选项卡中的"模块依赖性"后工作.

如何配置Intellij自动添加模块依赖?

请在下面找到相关代码.

常用模块的pom.xml:

<project ...>

<modelVersion>4.0.0</modelVersion>

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

...
Run Code Online (Sandbox Code Playgroud)

服务模块的pom.xml

...

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

...
Run Code Online (Sandbox Code Playgroud)

com.com.com.常见模块的客户.

package com.common;

public class Customer {
...
}
Run Code Online (Sandbox Code Playgroud)

class com.service.CustManager of service module.

package com.service;

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

public class CustManager {
...
}
Run Code Online (Sandbox Code Playgroud)