repackage failed: Unable to find main class

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了repackage failed: Unable to find main class相关的知识,希望对你有一定的参考价值。

一.错误信息
SpringBoot进行Maven install操作时报repackage failed: Unable to find main class -> [Help 1]的错误,信息如下

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.4.RELEASE:repackage (default) on project qfxSpringbootReadPropertiesDemo: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:2.0.4.RELEASE:repackage failed: Unable to find main class -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/PluginExecutionException

二.错误原因
因为没有正式环境的入口类,项目结构如下:

技术分享图片
pom.xml文件的<build>配置信息如下:

技术分享图片

三.解决方案1
pom.xml文件的<build>中指定入口类,代码如下

<configuration>
        <mainClass>com.qfx.App</mainClass>
</configuration>

如图

技术分享图片

四.解决方案2
去掉<build>配置信息中spring热部署的配置,如图

技术分享图片

五.解决方案3
修改pom.xml配置文件<build>内容如下,添加一个<pluginManagement>标签,代码如下

    <build>
        <finalName>test</finalName>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <dependencies>
                        <!-- spring热部署 -->
                        <dependency>
                            <groupId>org.springframework</groupId>
                            <artifactId>springloaded</artifactId>
                            <version>1.2.8.RELEASE</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

六.再次执行 Maven install,一切正常

以上是关于repackage failed: Unable to find main class的主要内容,如果未能解决你的问题,请参考以下文章

日常Exception第三十一回:repackage failed: Unable to find a single main class from the following candidate

日常Exception第三十一回:repackage failed: Unable to find a single main class from the following candidate

执行目标 org.springframework.boot:spring-boot-maven-plugin:2.4.4:repackage failed: 找不到主类的 default-cli

解决fabric “Authentication failed: failed classifying identity: Unable to extract msp“问题

Unable to load configuration.

struts报错严重: Dispatcher initialization failed Unable to load configuration.