问题描述
在搭建eureka-server应用时,编译打包后,使用jar -jar 方式启动,出现错误提示:没有主清单属性
$ java -jar eureka-1.0-SNAPSHOT.jar
eureka-1.0-SNAPSHOT.jar中没有主清单属性
原因分析:
在使用spring-boot-maven-plugin插件时,没有配置repackage, 从而导致没有将springboot启动类信息打包到jar,导致项目启动不了。
解决方案:
在pom.xml 文件中,使用:spring-boot-maven-plugin 时,需要配置以下:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>