首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >执行默认值-目标org.springframework.boot:spring-boot-maven-plugin:2.4.4:repackage的cli失败:找不到主类

执行默认值-目标org.springframework.boot:spring-boot-maven-plugin:2.4.4:repackage的cli失败:找不到主类
EN

Stack Overflow用户
提问于 2021-04-13 09:54:37
回答 2查看 4.1K关注 0票数 1

我是Springboot的新手,我试图重新创建我的教师应用程序,但是当我运行时遇到了一个错误。

mvn清洁包弹簧-启动:重新包装

这意味着它无法在后端模块中找到主类。错误消息:

智力测验的资料来源.成功0.386年代

资讯后端.失败11.162秒

资讯正面.跳过的信息

信息生成失败信息

项目后端执行目标org.springframework.boot:spring-boot-maven-plugin:2.4.4:repackage (默认-cli)失败:目标org.springframework.boot:spring-boot-maven-plugin:2.4.4:repackage的执行默认-cli失败:无法找到主类->帮助1

运行应用程序的@Springbootapplication主类位于前端模块中。我如何告诉应用程序呢?我尝试了这些步骤,在根pom文件中添加了一个springgboot-maven-plugin,但仍然没有成功。我还试图减少包的数量,使application.class尽可能接近src文件夹,尽管这些都不重要,因为它对我的老师有用。

这是我的根目录文件:

代码语言:javascript
运行
复制
<?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>

下面是后端模块pom:

代码语言:javascript
运行
复制
<?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>

项目结构的图像(我不允许在这里发布图像)

这里是我正在尝试重新创建的存储库。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-04-15 09:26:22

我找到了正确的方法来使用命令

mvn清洁包弹簧-启动:重新包装

是导航到只包含主类的模块(在我的例子中是前端模块),然后运行。

mvn清洁安装

其他人里面

票数 0
EN

Stack Overflow用户

发布于 2021-08-24 00:48:56

这里有类似的错误,我的代码找不到主类,我把这个属性添加到pom.xml文件中:

代码语言:javascript
运行
复制
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>

这里一切都很顺利。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67072601

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档