[英]Spring Boot Multi-Module maven project repackage failed
我目前正在關注 John Thompson 的 Spring Framework Beginner to Guru 課程。 我按照他的一步一步的程序,在 Spring Boot 上為 Spring Pet Clinic 創建多模塊 Maven 項目。 當我單擊根模塊上的包時,它說重新打包失敗,無法找到主類。
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[錯誤] 無法執行目標 org.springframework.boot:spring-boot-maven-plugin:2.1.6.RELEASE:repackage (repackage) on project pet-clinic-data: Execution repackage of goal org.springframework.boot:spring -boot-maven-plugin:2.1.6.RELEASE:repackage failed: Unable to find main class -> [Help 1]
消除
<configuration>
<skip>true</skip>
</configuration>
並添加“spring-boot.repackage.skip”屬性,如下所示:
<artifactId>pet-clinic-data</artifactId>
<properties>
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>
</properties>
spring-boot-maven-plugin 應該只在包含主類的模塊的 pom.xml 中。 看起來你有這個插件(或繼承)一個簡單的 jar 模塊,主模塊將用作依賴項。
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
主類使用@SpringBootApplication注解
您正在使用 spring-boot-maven-plugin:2.1.6.RELEASE。
從 Spring-Boot 2 開始,您不再需要 spring boot 插件。
您可以在聲明模塊的工件 id 后使用以下代碼。
<artifactId>pet-clinic-data</artifactId>
<properties>
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>
</properties>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.