当前位置: 首页 > 知识库问答 >
问题:

Maven deploy找不到外部项目依赖项

方谦
2023-03-14

在LoginStorageProviderFactory中,它有一个来自LoginStorageProvier的导入,在最后一个类中,它有一个来自外部项目(也是我的项目)中的用户类的导入。

如果我把这个用户类移到jar模块中,错误就会消失,并且一切都能很好地工作;但我的目标是将项目与用户在其他项目中的实现和EAR项目分离。

所以,我认为错误的原因是缺少依赖项,Maven不能解决它,也没有报告错误,只有Maven不能解决一个类,因为缺少依赖项。

<?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>gcs.fds</groupId>
    <artifactId>login-provider-focusoc</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <modules>
        <module>ear-module</module>
        <module>jar-module</module>
    </modules>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>

        <lombok.version>1.18.10</lombok.version>
        <jboss-logging.version>3.4.1.Final</jboss-logging.version>
        <keycloak.version>7.0.0</keycloak.version>

        <jboss.home>target/keycloak</jboss.home>
    </properties>

    <dependencies>
        <dependency> <!-- [THE OTHER PROJECT] -->
            <groupId>gcs.fds</groupId>
            <artifactId>focusoc</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <version>7</version>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>2.0.1.Final</version>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <includes>
                        <include>src</include>
                    </includes>
                </configuration>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>${project.basedir}/src/main/resources</directory>
                <filtering>true</filtering>
                <excludes>
                    <exclude>public/**</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>${project.basedir}/src/main/resources</directory>
                <filtering>false</filtering>
                <includes>
                    <include>public/**</include>
                </includes>
            </resource>
            <resource>
                <directory>${project.basedir}</directory>
                <includes>
                    <include>LICENSE.txt</include>
                </includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>${project.basedir}/target</directory>
                <includes>
                    <include>dependencies.txt</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

</project>
[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:2.0.1.Final:deploy (default-cli) on project login-provider-focusoc-module: Failed to execute goal deploy: {"WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-1" => {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"login-provider-focusoc-module-0.0.1-SNAPSHOT.jar\".POST_MODULE" => "WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"login-provider-focusoc-module-0.0.1-SNAPSHOT.jar\"
[ERROR]     Caused by: java.util.ServiceConfigurationError: org.keycloak.storage.UserStorageProviderFactory: Provider gcs.fds.focusoc.keycloak.spi.LoginStorageProviderFactory not found"}}}}
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:2.0.1.Final:deploy (default-cli) on project login-provider-focusoc-module: Failed to execute goal deploy: {"WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-1" => {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"login-provider-focusoc-module-0.0.1-SNAPSHOT.jar\".POST_MODULE" => "WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"login-provider-focusoc-module-0.0.1-SNAPSHOT.jar\"
    Caused by: java.util.ServiceConfigurationError: org.keycloak.storage.UserStorageProviderFactory: Provider gcs.fds.focusoc.keycloak.spi.LoginStorageProviderFactory not found"}}}}
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to execute goal deploy: {"WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-1" => {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"login-provider-focusoc-module-0.0.1-SNAPSHOT.jar\".POST_MODULE" => "WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"login-provider-focusoc-module-0.0.1-SNAPSHOT.jar\"
    Caused by: java.util.ServiceConfigurationError: org.keycloak.storage.UserStorageProviderFactory: Provider gcs.fds.focusoc.keycloak.spi.LoginStorageProviderFactory not found"}}}}
    at org.wildfly.plugin.deployment.AbstractDeployment.execute (AbstractDeployment.java:117)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :login-provider-focusoc-module

还有EAR模块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/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>login-provider-focusoc</artifactId>
        <groupId>gcs.fds</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>login-provider-focusoc-bundle</artifactId>
    <packaging>ear</packaging>

    <dependencies>
        <dependency>
            <groupId>gcs.fds</groupId>
            <artifactId>login-provider-focusoc-module</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <includeLibInApplicationXml>true</includeLibInApplicationXml>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>2.0.1.Final</version>
            </plugin>

        </plugins>
    </build>
</project>

和jar模块:

<?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">
    <parent>
        <artifactId>login-provider-focusoc</artifactId>
        <groupId>gcs.fds</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>login-provider-focusoc-module</artifactId>

    <dependencies>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-core</artifactId>
            <version>${keycloak.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-server-spi</artifactId>
            <version>${keycloak.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
            <version>${jboss-logging.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- demonstrates usage of custom dependencies in an ear -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>20.0</version>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.ejb</groupId>
            <artifactId>javax.ejb-api</artifactId>
            <version>3.2</version>
        </dependency>

        <dependency>
            <groupId>javax.persistence</groupId>
            <artifactId>javax.persistence-api</artifactId>
            <version>2.2</version>
        </dependency>

        <dependency>
            <groupId>gcs.fds</groupId>
            <artifactId>focusoc</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

</project>

共有1个答案

璩珂
2023-03-14

我想你的问题可以在这里得到回答:Maven模块+构建单个特定模块

我想现在你的EAR项目依赖于JAR项目。因此,在ear的pom.xml中,您应该将jar项目声明为依赖项。然后,您可以有多个选项通过Maven构建项目:

  1. 父目录中的“MVN clean install”:它将在本地目录中安装ear和jar
  2. jar项目中的“MVN clean Install”,然后在ear项目中的“MVN clean Install”。输出将与1相同。
  3. 如果您希望将来只需通过一个命令安装ear项目和相关的依赖项,请在父目录中运行'mvn install-pl ear-am'。
 类似资料:
  • 我和我的朋友正在做一个Java maven项目,它的设置和我们从Git得到的项目是一样的。在我的设置中,Maven正确地导入了所有依赖项,但对于我的朋友,它找不到任何依赖项。 我们尝试过的事情: 右键单击project,单击maven并单击Reimport。 我们都可以上网,所以这也不是问题。而且,Maven在IntelliJ中设置为自动导入。

  • 我对Clojure和Leiningen是新来的。刚开始工作一个现有的项目。我拉了回购并执行了Lein运行的命令。它抱怨说: “在clojars中找不到项目arcType:service.jose:jar:0.1.0-快照(https://repo.clojars.org/)无法将项目arcType:service.jar:0.1.0-快照从/传输到enonic(https://repo.enoni

  • 我在我的项目中使用了maven shade插件将所有依赖项jar类重新定位到一个包下,例如org.shade.* 当我试图在其他应用程序中使用带阴影的jar作为maven依赖项时,它会拉出依赖项jar的。 我的期望是,当Uber/shaded jar包含为maven依赖项时,它不应该拉出任何其他依赖类jar,因为这些类已经在shaded jar中重新打包了。

  • 我一直在使用gradle作为Springboot,它过去很好,但gradle的构建突然停止了工作。我不断收到错误,说找不到依赖项 这是分级代码: 我得到的错误是: 无法解析组织。springframework。启动:spring启动依赖项:2.4。1.无法解析io。关键的。Spring云:spring云服务依赖项:2.4。1.无法解析组织。springframework。云:spring云依赖项:

  • 我使用的是Maven 3.6.0,我有Spring Boot Maven项目,其pom文件如下: 出于某种原因,我在我的lib文件夹中发现了以下jarlog4j-1.2.14.jar.我想从我的最终战争中排除这个jar,所以我尝试了mvn依赖项:树,但我找不到父依赖项。 我还试图从Eclipse中打开依赖层次结构,但也找不到这个jar。我怎样才能排除这个罐子?

  • null 错误:找不到com.google.android.gms:play-services:6.5.87.在以下位置进行了搜索:file:/c:/users/myname/.m2/repository/com/google/android/gms/play-services/6.5.87.pom file:/c:/users/maname/.m2/repository/com/google/a