我刚刚开始使用 Maven 构建应用程序。我的一种方法是构建一个多模块 Web 应用程序。使用 Eclipse 可以很容易地构建这种应用程序。到目前为止一切正常。我失败的地方是部署。我使用 Wildfly 作为我的应用程序服务器,并且表示层的部署运行良好。但是当我想从父项目进行部署时,我收到了这条消息:
Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.0.1.Final:deploy (default-cli) on project build: Error executing FORCE_DEPLOY: C:\Users\*****\Desktop\workspace\mvnexbook-examples-1.0\ch-multi\target\parent-0.8-SNAPSHOT.maven-project (No such file or directory)
这非常令人困惑。不是从 .m2/repository 文件夹中先前安装的文件进行部署吗?我的父文件夹中是否需要一个目标目录?
我的父 pom 文件
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>simple-parent</artifactId>
<version>0.8-SNAPSHOT</version>
</parent>
<artifactId>simple-webapp</artifactId>
<packaging>war</packaging>
<name>Multi Chapter Simple Web Application Project</name>
<dependencies>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.4_spec</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>simple-weather</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<finalName>simple-webapp</finalName>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
编辑 : 我刚用码头试过。工作正常。为什么它不适用于 Wildfly?
编辑2 :我正在使用 sonatype 书中的 simple-parent-project 示例
最佳答案
在父 POM 中,您需要添加 <skip>true</skip>
到配置。然后设置为false
为您的 WAR POM。
父 POM
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.0.1.Final</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
war POM
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
关于Maven 无法从父 pom 部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23679539/