在cmd中运行springboot的jar包出现-没有主清单属性的提示
以我的springboot1.5.9版本为例
我的pom.xml文件导入如下依赖和插件
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.5.9.RELEASE</version>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
此时我进行打包时,Plugins中有错误提示,提示插件未知,但是打包却成功了,而运行的时候就提示没有主清单属性
解决方法
这是由于插件没有成功导入造成的。我们需要确定插件的版本;为了版本统一,我们使用依赖1.5.9的父项目来确定版本。这样可以最大程度减小出错概率。
把
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.5.9.RELEASE</version>
</dependency>
换为
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
再次打包即可。