天天看點

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] 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

二.錯誤原因

因為沒有正式環境的入口類,項目結構如下:

repackage failed: Unable to find main class

pom.xml檔案的配置資訊如下:

三.解決方案1

pom.xml檔案的中指定入口類,代碼如下

com.qfx.App

如圖

四.解決方案2

去掉配置資訊中spring熱部署的配置,如圖

五.解決方案3

修改pom.xml配置檔案内容如下,添加一個标簽,代碼如下

<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,一切正常(企業架構源碼可以加求球:三五三六二四七二五九)