我有一个maven pom如下:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MerchantWallet</groupId>
<artifactId>StellarReceive</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>StellarReceive Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<spring.version>4.3.8.RELEASE</spring.version>
<jdk.version>1.8</jdk.version>
</properties>
<dependencies>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- hello -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
</dependencies>
<build>
<finalName>StellarReceive</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
我在目标文件夹中看不到.war文件。有人可以帮忙吗
答案 0 :(得分:9)
首先,您必须使用战争类型包装来定义项目:
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<packaging>war</packaging>
然后你需要使用maven插件在编译时产生战争:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<attachClasses>true</attachClasses>
<webXml>target/web.xml</webXml>
<webResources>
<resource>
<directory>src/main/webapp</directory>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>
答案 1 :(得分:1)
尝试运行clean install
或clean package
maven命令。
项目&gt;以&gt;运行运行配置&gt;左侧面板中的maven构建&gt;右键单击&gt;新&gt;目标&gt; clean install
&gt;基目录&gt;选择当前的项目工作区。&gt;应用&GT;运行
clean package
或任何其他maven命令的相同方式。
如果它给出BUILD SUCCESS
那么就好了,否则将错误代码放在问题中。
答案 2 :(得分:0)
一种解决方案就是使用maven-war-plugin(https://maven.apache.org/plugins/maven-war-plugin/index.html)