简体   繁体   中英

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.
  2. Add Framework support to this project and pick: JSF.
  3. Go to pom.xml and add: packaging: war .
  4. And from Maven window in IntelliJ I click: Clean Install.

Well build fails, because maven is looking for a webapp directory instead of a directory called web . For building the project.

So, if I rename the folder web to webapp build goes fine.

However, I want to learn more about IntelliJ and maven, so I want to force maven to use the folder web . How can I properly do this

  • Using the command line? I mean without invvolving IntelliJ at all?
  • Using Intellij?

Regards.

You can configure this in the pom.xml file for your project.

<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.

Have a look at this post , which explains how to change the default webapp directory:

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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