Linux 執行jar包提示 no main manifest attribute
阿新 • • 發佈:2022-05-13
解決辦法:在pom檔案中新增如下依賴
解釋:
在sprinboot專案中pom.xml檔案加<includeSystemScope>true</includeSystemScope>,代表maven打包時會將外部引入的jar包(比如在根目錄下或resource檔案下新加外部jar包)打包到專案jar,在伺服器上專案才能執行,不加此配置,本地可以執行,因為本地可以再lib下找到外部包,但是伺服器上jar中是沒有的。
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<includeSystemScope>true </includeSystemScope>
<mainClass>這裡填寫自己主啟動類所在位置(包+類)</mainClass>
</configuration>
</plugin>
</plugins>
</build>