Maven无法从父pom部署

时间:2014-05-15 13:21:55

标签: maven jboss pom.xml wildfly multi-module

我刚刚开始使用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合作?

EDIT2 :我正在使用sonatype书中的简单父项目示例

2 个答案:

答案 0 :(得分:17)

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

答案 1 :(得分:1)

您的应用程序EAR可能不在父项目构建文件夹中。它可能位于APP模块构建项目中。如果您看到here:,您会看到, targetDir 默认构建当前项目的目录。您可以提供其他价值。 filename 参数指向filename。它默认为$ {project.build.finalName}。$ {project.packaging},在您的情况下,它没有有意义的扩展名。

您可能想尝试类似

的内容
        <configuration>
            <targetDir>path</targetDir>
            <filename>filename</filename>
        </configuration> 

你的插件防御。你当然可以使用相对路径。您也可以尝试从APP项目运行您的插件。