简体   繁体   English

构建战争文件时,如何告诉IntelliJ将文件夹“ web”而不是“ webapp”用于maven?

[英]How to tell IntelliJ to use folder “web” instead of “webapp” for maven when building a war file?

What I do is: 我要做的是:

  1. Create a new project with IntelliJ with Maven module. 使用带有Maven模块的IntelliJ创建一个新项目。
  2. Add Framework support to this project and pick: JSF. 向该项目添加Framework支持,然后选择:JSF。
  3. Go to pom.xml and add: packaging: war . 转到pom.xml并添加: 包装:war
  4. And from Maven window in IntelliJ I click: Clean Install. 从IntelliJ的Maven窗口中,单击:全新安装。

Well build fails, because maven is looking for a webapp directory instead of a directory called web . 构建失败,因为maven正在寻找一个webapp目录而不是一个名为web的目录。 For building the project. 用于构建项目。

So, if I rename the folder web to webapp build goes fine. 因此,如果我将文件夹Web重命名为webapp,构建就可以了。

However, I want to learn more about IntelliJ and maven, so I want to force maven to use the folder web . 但是,我想了解有关IntelliJ和maven的更多信息,所以我想强制maven使用文件夹web How can I properly do this 我该如何正确地做到这一点

  • Using the command line? 使用命令行? I mean without invvolving IntelliJ at all? 我的意思是根本不参与IntelliJ吗?
  • Using Intellij? 使用Intellij吗?

Regards. 问候。

You can configure this in the pom.xml file for your project. 您可以在项目的pom.xml文件中进行配置。

<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
      <warSourceDirectory>web</warSourceDirectory>
    </configuration>
  </plugin>
</plugins>

You can find the documentation here 您可以在这里找到文档

If IntelliJ behaves as expected, it should pick up this new configuration. 如果IntelliJ的行为符合预期,则应选择此新配置。

Have a look at this post , which explains how to change the default webapp directory: 看一下这篇文章 ,其中说明了如何更改默认的webapp目录:

<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.3</version>
        <configuration>
          <warSourceDirectory>web</warSourceDirectory>
        </configuration>
      </plugin>
    </plugins>
</build>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM