maven打包repackage failed: Unable to find main class

maven打包提示这个问题。

原因:主项目pomxml文件中,不需要<build>打包的配置,只需要在有入口类的模块pom.xml配置好<build>

 <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot.version}</version>
                <configuration>
                    <includeSystemScope>true</includeSystemScope><!--将resources目录外部引入的三方jar包打入最终的jar包中-->
                </configuration>

                <executions>
                    <execution>
                        <configuration>
                            <mainClass>com.kuailaimi.ClientApplication</mainClass>
                        </configuration>
                        <goals>
                            <goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中-->
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>application.yml</include>
                    <include>application-${environment}.yml</include>
                    <include>logback/logback-${environment}.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

 

posted @ 2023-07-14 19:43  White_白  阅读(834)  评论(0编辑  收藏  举报