Exception in thread “main“ java.lang.reflect.InvocationTargetException缺失主函数

springboot项目打包后,发布报错Exception in thread "main" java.lang.reflect.InvocationTargetException,原因是MANIFEST.MF文件没有指定启动的主函数类
在这里插入图片描述解决方法:在pom.xml添加如下配置

<build>
    <plugins>
	   <plugin>
	      <groupId>org.springframework.boot</groupId>
	      <artifactId>spring-boot-maven-plugin</artifactId>
	      <version>1.4.2.RELEASE</version>
	      <configuration>
	           <source>1.8</source>
	           <target>1.8</target>
	           <archive>
	              <manifest>
	                 <mainClass>com.example.hbase.SpringbootApplication</mainClass><!--  springboot启动类-->
	                 <addClasspath>true</addClasspath>
	                 <classpathPrefix>lib/</classpathPrefix>
	               </manifest>
	            </archive>
	       </configuration>
	       <executions>
	          <execution>
	             <goals>
	                <goal>repackage</goal>
	             </goals>
	          </execution>
	        </executions>
	     </plugin>
	     <plugin>
 			<groupId>org.apache.maven.plugins</groupId>
 			<artifactId>maven-compiler-plugin</artifactId>
 			<version>3.8.1</version>
 			<configuration>
     			<source>1.8</source>
     			<target>1.8</target>
 			</configuration>
		</plugin>
 		</plugins>
	</build>

使用maven进行打包
第一步,清理
在这里插入图片描述
第二步
Run As=》Maven insert进行项目打包
在这里插入图片描述
第三步
根据打包路径找到jar包
在这里插入图片描述


版权声明:本文为weixin_42933886原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。