我的任务是将应用程序构建到 WAR 存档中。我有以下内容pom.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.modularplatform</groupId>
<artifactId>ModularPlatform</artifactId>
<version>0.0.1</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>9.0.10</version>
</dependency>
</dependencies>
<build>
<outputDirectory>build/</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/</directory>
<includes>
<include>*</include>
<include>s/*</include>
</includes>
</resource>
<resource>
<directory>src/main/webapp/</directory>
<includes>
<include>*</include>
<include>WEB-INF/*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<attachClasses>true</attachClasses>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
编译后,build/
目录下没有war包。我究竟做错了什么?
PS 我用 InteliJIdea
IJ 在编译时不编译 war 文件。您需要通过在 Maven 项目窗口中运行包目标或使用命令行来构建
从项目的根文件夹中。
顺便说一句,如果您打开终端窗口,则可以在不离开环境的情况下运行该命令。