当我在项目的pom.xml中手动添加依赖项时,让Maven下载依赖项并让IntelliJ构建模块,IntelliJ抱怨缺少库.同时,Maven可以找到依赖的JAR并构建项目.
如何告诉IntelliJ使用Maven下载的库?
需要创建一个由注册模块和主项目组成的多模块maven项目.问题是不可能使用在不同模块中声明的类.
例如:我ParentClaz在父母的src/main/java目录和ChildClaz子目录的src/main/java目录中有一个.现在这是不可能既不使用ParentClaz中ChildClaz也不反之亦然.
该项目的结构如下所示:
+-- AdminPortal <- parent root
+-- registration <- child root
-- pom.xml <- child pom
-- pom.xml <- parent pom
Run Code Online (Sandbox Code Playgroud)
我的AdminPortal POM:
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>AdminPortal</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>AdminPortal</name>
<url>http://maven.apache.org</url>
<modules>
<module>registration</module>
</modules>
Run Code Online (Sandbox Code Playgroud)
这是孩子POM:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>AdminPortal</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.example.AdminPortal</groupId>
<artifactId>registration</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>registration</name>
<url>http://maven.apache.org</url>
Run Code Online (Sandbox Code Playgroud)
怎样才能解决这个问题?