Maven 和 Intellij 构建方式不同

She*_*ari 5 java intellij-idea maven dropwizard

我有一个家长 pom。当我在父级上并编写mvn clean install我的 dropwizard 应用程序时,构建得很好。

但是,在 Intellij 中它失败了,因为它找不到我的config.yml文件。

问题是我需要在 Intellij 中包含我的模块目录,而不是在 Maven 中。这是为什么?

运行mvn install这个作品

public static void main(String[] args) throws Exception {
    new CivilizationApplication().run(new String[]{"server", "src/main/resources/config.yml"});
}
Run Code Online (Sandbox Code Playgroud)

在 Intellij 中我必须更改为以下内容

public static void main(String[] args) throws Exception {
    new CivilizationApplication().run(new String[]{"server", "civilization-rest/src/main/resources/config.yml"});
}
Run Code Online (Sandbox Code Playgroud)

如何配置 Intellij,使其无需指定模块目录即可工作?

小智 3

您可以尝试在运行配置中设置工作目录...

在此输入图像描述

我还会查看您的pom.xml配置,看看您是否可以在导入 Maven 项目时更改工作源集以使用此目录。