简体   繁体   English

执行目标 org.springframework.boot:spring-boot-maven-plugin:2.4.4:repackage 的 default-cli 失败:无法找到主 class

[英]Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.4.4:repackage failed: Unable to find main class

I am new to Springboot and trying to re-create my teachers application, but I get an error when I run我是 Springboot 的新手,正在尝试重新创建我的教师应用程序,但运行时出现错误

mvn clean package spring-boot:repackage mvn clean package spring-boot:重新包装

that says it cannot find main class in backend module.这表示它在后端模块中找不到主要的 class。 Error message:错误信息:

[INFO] Root of quiz....................................... SUCCESS [ 0.386 s] [INFO] 测验的根源.......................................成功 [ 0.386 s]

[INFO] backend............................................ FAILURE [ 11.162 s] [信息] 后端................................. 失败 [ 11.162 秒]

[INFO] frontend........................................... SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] 前端.......................... 跳过 [INFO ] ------------------------------------------------- ----------------------

[INFO] BUILD FAILURE [INFO] ----------------------------------------------------------------- [信息] 构建失败 [信息] ------------------------------------------ ----------------------

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.4:repackage (default-cli) on project backend: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.4.4:repackage failed: Unable to find main class -> [Help 1] [错误] 无法在项目后端执行目标 org.springframework.boot:spring-boot-maven-plugin:2.4.4:repackage (default-cli):执行目标 org.springframework.boot:spring-boot 的 default-cli -maven-plugin:2.4.4:repackage failed: Unable to find main class -> [帮助 1]

The @Springbootapplication main class that runs the application is in frontend module.运行应用程序的@Springbootapplication main class 位于前端模块中。 How do I tell the application that?我如何告诉应用程序? I tried these steps by adding a springgboot-maven-plugin in root pom file with still no luck.我通过在根 pom 文件中添加 springgboot-maven-plugin 来尝试这些步骤,但仍然没有运气。 I also tried to reduce the number of packages and make the application.class as close as possible to src folder, even though none of these things should matter because it works on my teachers.我还尝试减少包的数量并使 application.class 尽可能靠近 src 文件夹,尽管这些都不重要,因为它适用于我的老师。

Here is my root pom file:这是我的根 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">

  <modelVersion>4.0.0</modelVersion>

  <artifactId>quiz</artifactId>
  <groupId>org.quiz</groupId>
  <packaging>pom</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>Root of quiz</name>

  <modules>
    <module>backend</module>
    <module>fronten</module>
  </modules>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <fs>${file.separator}</fs>
    <version.java>11</version.java>
    <version.jacoco>0.8.5</version.jacoco>
    <!--  FIXME version 1.4.200 breaks tests, eg in JPA-JPQL  -->
    <version.h2>1.4.197</version.h2>
    <version.testcontainers>1.15.1</version.testcontainers>
    <version.selenium>3.141.59</version.selenium>
    <version.springboot>2.3.5.RELEASE</version.springboot>
    <version.junit>5.7.0</version.junit>
    <version.junit.platform>1.5.2</version.junit.platform>
    <!--
        TODO: cannot update to 4.3+ as conflicts of major versioning
        of Groovy runtime
    -->
    <version.surefire-failsafe>3.0.0-M4</version.surefire-failsafe>
    <version.hibernate.validator>6.1.0.Final</version.hibernate.validator>
    <version.hibernate.core>5.3.7.Final</version.hibernate.core>
    <version.javax.el>3.0.0</version.javax.el>
    <version.javax.javae.api>8.0.1</version.javax.javae.api>
    <jbossTarget>${basedir}/target/downloaded_Wildfly</jbossTarget>
    <jbossHome>${jbossTarget}/wildfly</jbossHome>
    <!--  When updating this version, must also update Dockerfile using jboss/wildfly 
 images-->
    <version.wildfly>18.0.1.Final</version.wildfly>
  </properties>

  <dependencies>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter</artifactId>
    </dependency>
  </dependencies>

  <dependencyManagement>
    <dependencies>
        <!-- SpringBoot BOM -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>${version.springboot}</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>${version.springboot}</version>
            <scope>test</scope>
            <!-- Exclude JUnit 4, which is added by default-->
            <exclusions>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!--Hibernate-->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${version.hibernate.core}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>${version.hibernate.validator}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Database -->
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.4.197</version>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.1.4</version>
        </dependency>

        <!--Containers, all needed??-->
        <dependency>
            <!-- Note: this has the other as dependency -->
            <groupId>org.glassfish</groupId>
            <artifactId>javax.el</artifactId><!--Db-->
            <version>${version.javax.el}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <version>2.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.core</groupId>
            <artifactId>arquillian-core-api</artifactId>
            <version>1.5.0.Final</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wildfly.arquillian</groupId>
            <artifactId>wildfly-arquillian-container-managed</artifactId>
            <version>2.2.0.Final</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <version>1.5.0.Final</version>
            <!-- make sure it is in test scope -->
            <scope>test</scope>
        </dependency>

        <!-- Junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${version.junit}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <version>${version.junit}</version>
            <scope>test</scope>
        </dependency>



        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <version>2.0</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.el</groupId>
                    <artifactId>javax.el-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp.jstl</groupId>
            <artifactId>javax.servlet.jsp.jstl-api</artifactId>
            <version>1.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.joinfaces</groupId>
            <artifactId>jsf-spring-boot-starter</artifactId>
            <!--
                This depends on Spring version, see:
                https://github.com/joinfaces/joinfaces
                However, SpringBoot 2.1 would require 4.x (eg 4.0.9) here,
                but it does not work, whereas 3.2 is fine...
            -->
            <version>3.2.3</version>
        </dependency>

        <!--Selenium-->
        <dependency>
            <!-- used to control a browser for system testing -->
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>${version.selenium}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <!-- used to control a browser for system testing -->
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-api</artifactId>
            <version>${version.selenium}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <!-- used to control a browser for system testing -->
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-chrome-driver</artifactId>
            <version>${version.selenium}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <!-- used to control a browser for system testing -->
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-remote-driver</artifactId>
            <version>${version.selenium}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <!-- used to control a browser for system testing -->
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-support</artifactId>
            <version>${version.selenium}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <!-- for code coverage -->
            <groupId>org.jacoco</groupId>
            <artifactId>org.jacoco.core</artifactId>
            <version>${version.jacoco}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <!-- To use Docker from tests -->
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <version>${version.testcontainers}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <!-- To support JUnit 5  -->
            <groupId>org.testcontainers</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${version.testcontainers}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>selenium</artifactId>
            <version>${version.testcontainers}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-remote-driver</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

    </dependencies>
  </dependencyManagement>




  <build>
    <pluginManagement>
        <plugins>
            <plugin>
                <!-- Need to create self-executable uber/fat jars for SpringBoot -->
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${version.springboot}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <!-- Used to download and unpack JBoss/Wildfly automatically before running the 
 tests-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>process-test-classes</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.wildfly</groupId>
                                    <artifactId>wildfly-dist</artifactId>
                                    <version>${version.wildfly}</version>
                                    <type>zip</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${jbossTarget}</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Built-in plugin used to compile Java code -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <inherited>true</inherited>
                <configuration>
                    <release>${version.java}</release>
                </configuration>
            </plugin>

            <!-- For running ANT tasks, like renaming files/folders -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.8</version>
            </plugin>
            <!--
          When unzipping Wildfly, the folder name will contain the version.
          This is not good, as then we would need to hardcode such version
          in each Arquillian file.
          So, we make sure to rename such folder.
          Why? If then we change Wildfly version, we only update such value
          here in the pom file, and not in every single Arquillian file...
      -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>Rename Wildfly folder</id>
                        <phase>process-test-classes</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <move file="${jbossTarget}/wildfly-${version.wildfly}"
                                      tofile="${jbossTarget}/wildfly"
                                      failonerror="false"
                                />
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- this is needed to run integration tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${version.surefire-failsafe}</version>
                <configuration>
                    <forkCount>1</forkCount>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                    <rerunFailingTestsCount>3</rerunFailingTestsCount>
                    <argLine>-Xms512m -Xmx4096m</argLine>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- Built-in plugin used to execute unit tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${version.surefire-failsafe}</version>
                <configuration>
                    <forkCount>1</forkCount>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                    <rerunFailingTestsCount>3</rerunFailingTestsCount>
                    <argLine>-Xms512m -Xmx2048m</argLine>
                </configuration>
            </plugin>


            <!-- Avoid failing War generation if web.xml is missing, as we ll not
             use it in some example modules -->
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>

            <!-- For cloud deployment on Heroku -->
            <plugin>
                <groupId>com.heroku.sdk</groupId>
                <artifactId>heroku-maven-plugin</artifactId>
                <version>2.0.2</version>
            </plugin>

            <!--code coverage-->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${version.jacoco}</version>
                <executions>
                    <execution>
                        <id>default-prepare-agent</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-prepare-agent-integration</id>
                        <phase>package</phase>
                        <goals>
                            <goal>prepare-agent-integration</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-report-integration</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>report-integration</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>
 </build>

</project>

Here is the backend module pom:这是后端模块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">

<modelVersion>4.0.0</modelVersion>
<version>1.0-SNAPSHOT</version>

<parent>
    <artifactId>quiz</artifactId>
    <groupId>org.quiz</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>

<artifactId>backend</artifactId>
<groupId>org.quiz.backend</groupId>
<packaging>jar</packaging>

<dependencies>
    <dependency>
        <groupId>javax.enterprise</groupId>
        <artifactId>cdi-api</artifactId>
    </dependency>

    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
    </dependency>

    <!--Springboot, versions are retrieved from springboot BOM (pom) in parent pom-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <!--Database-->
    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-core</artifactId>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <!-- For code coverage -->
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
        </plugin>

        <!-- Built-in plugin used to execute unit tests, (TODO: tests passes without this 
 too) -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <forkCount>1</forkCount>
                <redirectTestOutputToFile>true</redirectTestOutputToFile>
                <rerunFailingTestsCount>3</rerunFailingTestsCount>
                 <!--suppress UnresolvedMavenProperty -->
                <argLine>${argLine} -Xms512m -Xmx4096m</argLine>
            </configuration>
        </plugin>
    </plugins>
  </build>
</project>

Image of project structure (I was not allowed to post the image here)项目结构图(我不允许在这里发布图片)

Here is the repository I am trying to re-create 这是我要重新创建的存储库

I had the similar error here, my code doesn't find the main class, I added this property to pom.xml file:我在这里遇到了类似的错误,我的代码没有找到主要的 class,我将此属性添加到 pom.xml 文件中:

<spring-boot.repackage.skip>true</spring-boot.repackage.skip>

And everything worked here.一切都在这里工作。

I found out the right way to use the command我找到了使用命令的正确方法

mvn clean package spring-boot:repackage mvn clean package spring-boot:重新包装

is to navigate to the module that contains the main class only (in my case the frontend module) and then run是导航到仅包含主要 class 的模块(在我的情况下为前端模块),然后运行

mvn clean install mvn 干净安装

inside the others在别人里面

暂无
暂无

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

相关问题 目标org.springframework.boot的执行默认值:spring-boot-maven-plugin:1.4.0.RELEASE:repackage failed: Unable to rename - Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.4.0.RELEASE:repackage failed: Unable to rename 无法执行目标 org.springframework.boot:spring-boot-maven-plugin:2.1.12.RELEASE:run (default-cli) - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.12.RELEASE:run (default-cli) 无法执行目标 org.springframework.boot:spring-boot-maven-plugin:2.5.5:run (default-cli) - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.5.5:run (default-cli) 无法在项目用户上执行目标 org.springframework.boot:spring-boot-maven-plugin:2.6.7:run (default-cli): - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.6.7:run (default-cli) on project userms: 未能执行目标 org.springframework.boot:spring-boot-maven-plugin:2.2.5.RELEASE:run (default-cli) - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.5.RELEASE:run (default-cli) 构建 docker 镜像时出错,无法在项目上执行目标 org.springframework.boot:spring-boot-maven-plugin:2.5.2:build-image (default-cli) - Error while building docker image, Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.5.2:build-image (default-cli) on project 无法在项目 someProject 上执行目标 org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:run (default-cli):无法执行 java - Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:run (default-cli) on project someProject: Could not exec java 目标org.springframework.boot的执行默认值:spring-boot-maven-plugin:1.2.3.RELEASE:repackage failed:Source必须引用现有文件 - Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.2.3.RELEASE:repackage failed: Source must refer to an existing file 目标的执行默认值 org.springframework.boot:spring-boot-maven-plugin:1.0.2.RELEASE:repackage failed: Source must refer to an existing file - Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.0.2.RELEASE:repackage failed: Source must refer to an existing file 无法在插件org.springframework.boot中找到目标:&#39;spring-boot-maven-plugin:1.1.4.RELEASE可用目标重新打包 - Could not find goal '' in plugin org.springframework.boot:spring-boot-maven-plugin:1.1.4.RELEASE among available goals repackage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM