問題:
在進行docker部署的時候,開始對項目進行打包,在啟動該鏡像時
[root@topcheer docker]# docker run -it 00494e3d4550
no main manifest attribute, in /app.jar
提示沒有入口類信息
解決:
項目基於maven pom多模塊的開發的,需要設置goal-repackage屬性為true,否則打包后文件依賴文件沒有一起打包,然后鏡像內沒有可以運行的程序文件
如下:2個打包插件都要,不然只有docker的會導致打包不完整。
<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> </configuration> </plugin> <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>1.2.0</version> <executions> <execution> <phase>package</phase> <goals> <goal>build</goal> </goals> </execution> <execution> <id>tag-image</id> <phase>package</phase> <goals> <goal>tag</goal> </goals> <configuration> <image>${docker.repostory}/${docker.image.prefix}/${project.artifactId}:1.0.1</image> <newName>${docker.repostory}/${docker.image.prefix}/${project.artifactId}:1.0.1</newName> </configuration> </execution>