简体   繁体   English

maven wildfly 部署无法解析依赖项

[英]maven wildfly deploy could not resolve dependencies

I have a maven project with two modules: core and webapp.我有一个带有两个模块的 maven 项目:core 和 webapp。 The webapp module is a war file to be deployed to wildfly. webapp 模块是要部署到wildfly 的war 文件。 It has a dependency to the core module.它依赖于核心模块。

I can run mvn clean package in the parent directory of my modules.我可以在我的模块的父目录中运行mvn clean package I am able to deploy de war file manually to wildfly and it works.我能够手动将 de war 文件部署到 wildfly 并且它可以工作。 Unfortunately if I run mvn wildfly:deploy in the webapp directory I get:不幸的是,如果我在 webapp 目录中运行mvn wildfly:deploy我得到:

Failed to execute goal on project webapp: Could not resolve dependencies for project gbt:webapp:war:1.0-SNAPSHOT: Could not find artifact gbt:core:jar:1.0-SNAPSHOT

What shall I do to deploy the war file with the wildfly plugin?怎么用wildfly插件部署war文件?

parent pom父母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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>gbt</groupId>
    <artifactId>unite_compte</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <version.server.bom>25.0.1.Final</version.server.bom>
        <version.microprofile.bom>25.0.1.Final</version.microprofile.bom>
        <jakartaee.version>8.0.0</jakartaee.version>
        <version.wildfly.maven.plugin>2.1.0.Final</version.wildfly.maven.plugin>
        <failOnMissingWebXml>false</failOnMissingWebXml>
    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- importing the jakartaee8-with-tools BOM adds specs and other useful artifacts as managed dependencies -->
            <dependency>
                <groupId>org.wildfly.bom</groupId>
                <artifactId>wildfly-jakartaee8-with-tools</artifactId>
                <version>${version.server.bom}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>


    <dependencies>
        <dependency>
            <groupId>jakarta.platform</groupId>
            <artifactId>jakarta.jakartaee-api</artifactId>
            <version>${jakartaee.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.wildfly.plugins</groupId>
                    <artifactId>wildfly-maven-plugin</artifactId>
                    <version>${version.wildfly.maven.plugin}</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <modules>
        <module>core</module>
        <module>webapp</module>
    </modules>
</project>

webapp 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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>gbt</groupId>
        <artifactId>unite_compte</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <groupId>gbt</groupId>
    <artifactId>webapp</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <dependencies>
        <dependency>
            <groupId>gbt</groupId>
            <artifactId>core</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <build>
        <!--finalName>${project.artifactId}</finalName-->
        <finalName>unite_compte</finalName>
        <plugins>
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

core pom核心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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>gbt</groupId>
        <artifactId>unite_compte</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <groupId>gbt</groupId>
    <artifactId>core</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <dependencies>

    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
    </build>
</project>

You need to run mvn install , or the artifact for the core module is built but never installed into the local repository and cannot be resolved when building the webapp module.您需要运行mvn install ,否则core模块的工件已构建但从未安装到本地存储库中,并且在构建webapp模块时无法解析。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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