[运行报错] Maven打包SpringBoot项目,运行报错:no main manifest attribute, in xxx.jar

文章目录

    • 问题描述
    • 解决办法
    • 附录

问题描述

IDEA创建SpringBoot 2.6.13项目(仅引入SpringMVC依赖),对生成的代码不做修改直接Maven打包。但运行报错:

# java -jar xxx.jar 
no main manifest attribute, in xxx.jar

检查jar包,

# jar -xvf xxx.jar 
# cat META-INF/MANIFEST.MF 
Manifest-Version: 1.0
Build-Jdk-Spec: 1.8
Created-By: Maven JAR Plugin 3.3.0

解决办法

pom.xml中注释掉创建时spring-boot-maven-plugin<configuration><skip>true</skip>(忽略配置):

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot.version}</version>
                <configuration>
                    <mainClass>com.example.MinWebDemoApplication</mainClass>
<!--                    <skip>true</skip>-->

重新用maven打包(先clean, 再package),即可✅。

注意到,此时META-INF/MANIFEST.MF包含了Start-Class和Main-Class

# jar -xvf xxx.jar 
# cat META-INF/MANIFEST.MF 
...
Start-Class: com.example.MinWebDemoApplication
...
Main-Class: org.springframework.boot.loader.JarLauncher

附录

root@node01:~/web-app# java -jar min-web-demo-0.0.1-SNAPSHOT.jar 
no main manifest attribute, in min-web-demo-0.0.1-SNAPSHOT.jar

root@node01:~/web-app# jar -xvf min-web-demo-0.0.1-SNAPSHOT.jar 
  created: META-INF/
 inflated: META-INF/MANIFEST.MF
  created: com/
  created: com/example/
  created: com/example/demos/
  created: com/example/demos/web/
  created: static/
  created: META-INF/maven/
  created: META-INF/maven/com.example/
  created: META-INF/maven/com.example/min-web-demo/
 inflated: application.properties
 inflated: com/example/demos/web/BasicController.class
 inflated: com/example/demos/web/PathVariableController.class
 inflated: com/example/demos/web/User.class
 inflated: com/example/MinWebDemoApplication.class
 inflated: static/index.html
 inflated: META-INF/maven/com.example/min-web-demo/pom.xml
 inflated: META-INF/maven/com.example/min-web-demo/pom.properties
root@node01:~/web-app# cat META-INF/MANIFEST.MF 
Manifest-Version: 1.0
Build-Jdk-Spec: 1.8
Created-By: Maven JAR Plugin 3.3.0

root@node01:~/web-app# jar -xvf min-web-demo-0.0.2-SNAPSHOT.jar 
  created: META-INF/
 inflated: META-INF/MANIFEST.MF
  created: org/
  created: org/springframework/
  created: org/springframework/boot/
  created: org/springframework/boot/loader/
 inflated: org/springframework/boot/loader/ClassPathIndexFile.class
 inflated: org/springframework/boot/loader/ExecutableArchiveLauncher.class
 inflated: org/springframework/boot/loader/JarLauncher.class
 inflated: org/springframework/boot/loader/LaunchedURLClassLoader$DefinePackageCallType.class
 inflated: org/springframework/boot/loader/LaunchedURLClassLoader$UseFastConnectionExceptionsEnumeration.class
 inflated: org/springframework/boot/loader/LaunchedURLClassLoader.class
 inflated: org/springframework/boot/loader/Launcher.class
 inflated: org/springframework/boot/loader/MainMethodRunner.class
 inflated: org/springframework/boot/loader/PropertiesLauncher$1.class
 inflated: org/springframework/boot/loader/PropertiesLauncher$ArchiveEntryFilter.class
 inflated: org/springframework/boot/loader/PropertiesLauncher$ClassPathArchives.class
 inflated: org/springframework/boot/loader/PropertiesLauncher$PrefixMatchingArchiveFilter.class
 inflated: org/springframework/boot/loader/PropertiesLauncher.class
 inflated: org/springframework/boot/loader/WarLauncher.class
  created: org/springframework/boot/loader/archive/
 inflated: org/springframework/boot/loader/archive/Archive$Entry.class
 inflated: org/springframework/boot/loader/archive/Archive$EntryFilter.class
 inflated: org/springframework/boot/loader/archive/Archive.class
 inflated: org/springframework/boot/loader/archive/ExplodedArchive$AbstractIterator.class
 inflated: org/springframework/boot/loader/archive/ExplodedArchive$ArchiveIterator.class
 inflated: org/springframework/boot/loader/archive/ExplodedArchive$EntryIterator.class
 inflated: org/springframework/boot/loader/archive/ExplodedArchive$FileEntry.class
 inflated: org/springframework/boot/loader/archive/ExplodedArchive$SimpleJarFileArchive.class
 inflated: org/springframework/boot/loader/archive/ExplodedArchive.class
 inflated: org/springframework/boot/loader/archive/JarFileArchive$AbstractIterator.class
 inflated: org/springframework/boot/loader/archive/JarFileArchive$EntryIterator.class
 inflated: org/springframework/boot/loader/archive/JarFileArchive$JarFileEntry.class
 inflated: org/springframework/boot/loader/archive/JarFileArchive$NestedArchiveIterator.class
 inflated: org/springframework/boot/loader/archive/JarFileArchive.class
  created: org/springframework/boot/loader/data/
 inflated: org/springframework/boot/loader/data/RandomAccessData.class
 inflated: org/springframework/boot/loader/data/RandomAccessDataFile$1.class
 inflated: org/springframework/boot/loader/data/RandomAccessDataFile$DataInputStream.class
 inflated: org/springframework/boot/loader/data/RandomAccessDataFile$FileAccess.class
 inflated: org/springframework/boot/loader/data/RandomAccessDataFile.class
  created: org/springframework/boot/loader/jar/
 inflated: org/springframework/boot/loader/jar/AbstractJarFile$JarFileType.class
 inflated: org/springframework/boot/loader/jar/AbstractJarFile.class
 inflated: org/springframework/boot/loader/jar/AsciiBytes.class
 inflated: org/springframework/boot/loader/jar/Bytes.class
 inflated: org/springframework/boot/loader/jar/CentralDirectoryEndRecord$1.class
 inflated: org/springframework/boot/loader/jar/CentralDirectoryEndRecord$Zip64End.class
 inflated: org/springframework/boot/loader/jar/CentralDirectoryEndRecord$Zip64Locator.class
 inflated: org/springframework/boot/loader/jar/CentralDirectoryEndRecord.class
 inflated: org/springframework/boot/loader/jar/CentralDirectoryFileHeader.class
 inflated: org/springframework/boot/loader/jar/CentralDirectoryParser.class
 inflated: org/springframework/boot/loader/jar/CentralDirectoryVisitor.class
 inflated: org/springframework/boot/loader/jar/FileHeader.class
 inflated: org/springframework/boot/loader/jar/Handler.class
 inflated: org/springframework/boot/loader/jar/JarEntry.class
 inflated: org/springframework/boot/loader/jar/JarEntryCertification.class
 inflated: org/springframework/boot/loader/jar/JarEntryFilter.class
 inflated: org/springframework/boot/loader/jar/JarFile$1.class
 inflated: org/springframework/boot/loader/jar/JarFile$JarEntryEnumeration.class
 inflated: org/springframework/boot/loader/jar/JarFile.class
 inflated: org/springframework/boot/loader/jar/JarFileEntries$1.class
 inflated: org/springframework/boot/loader/jar/JarFileEntries$EntryIterator.class
 inflated: org/springframework/boot/loader/jar/JarFileEntries$Offsets.class
 inflated: org/springframework/boot/loader/jar/JarFileEntries$Zip64Offsets.class
 inflated: org/springframework/boot/loader/jar/JarFileEntries$ZipOffsets.class
 inflated: org/springframework/boot/loader/jar/JarFileEntries.class
 inflated: org/springframework/boot/loader/jar/JarFileWrapper.class
 inflated: org/springframework/boot/loader/jar/JarURLConnection$1.class
 inflated: org/springframework/boot/loader/jar/JarURLConnection$JarEntryName.class
 inflated: org/springframework/boot/loader/jar/JarURLConnection.class
 inflated: org/springframework/boot/loader/jar/StringSequence.class
 inflated: org/springframework/boot/loader/jar/ZipInflaterInputStream.class
  created: org/springframework/boot/loader/jarmode/
 inflated: org/springframework/boot/loader/jarmode/JarMode.class
 inflated: org/springframework/boot/loader/jarmode/JarModeLauncher.class
 inflated: org/springframework/boot/loader/jarmode/TestJarMode.class
  created: org/springframework/boot/loader/util/
 inflated: org/springframework/boot/loader/util/SystemPropertyUtils.class
  created: BOOT-INF/
  created: BOOT-INF/classes/
  created: BOOT-INF/classes/com/
  created: BOOT-INF/classes/com/example/
  created: BOOT-INF/classes/com/example/demos/
  created: BOOT-INF/classes/com/example/demos/web/
  created: BOOT-INF/classes/static/
  created: META-INF/maven/
  created: META-INF/maven/com.example/
  created: META-INF/maven/com.example/min-web-demo/
 inflated: BOOT-INF/classes/application.properties
 inflated: BOOT-INF/classes/com/example/demos/web/BasicController.class
 inflated: BOOT-INF/classes/com/example/demos/web/PathVariableController.class
 inflated: BOOT-INF/classes/com/example/demos/web/User.class
 inflated: BOOT-INF/classes/com/example/MinWebDemoApplication.class
 inflated: BOOT-INF/classes/static/index.html
 inflated: META-INF/maven/com.example/min-web-demo/pom.xml
 inflated: META-INF/maven/com.example/min-web-demo/pom.properties
  created: BOOT-INF/lib/
extracted: BOOT-INF/lib/spring-boot-2.6.13.jar
extracted: BOOT-INF/lib/spring-boot-autoconfigure-2.6.13.jar
extracted: BOOT-INF/lib/logback-classic-1.2.11.jar
extracted: BOOT-INF/lib/logback-core-1.2.11.jar
extracted: BOOT-INF/lib/log4j-to-slf4j-2.17.2.jar
extracted: BOOT-INF/lib/log4j-api-2.17.2.jar
extracted: BOOT-INF/lib/jul-to-slf4j-1.7.36.jar
extracted: BOOT-INF/lib/jakarta.annotation-api-1.3.5.jar
extracted: BOOT-INF/lib/snakeyaml-1.29.jar
extracted: BOOT-INF/lib/jackson-databind-2.13.4.2.jar
extracted: BOOT-INF/lib/jackson-annotations-2.13.4.jar
extracted: BOOT-INF/lib/jackson-core-2.13.4.jar
extracted: BOOT-INF/lib/jackson-datatype-jdk8-2.13.4.jar
extracted: BOOT-INF/lib/jackson-datatype-jsr310-2.13.4.jar
extracted: BOOT-INF/lib/jackson-module-parameter-names-2.13.4.jar
extracted: BOOT-INF/lib/tomcat-embed-core-9.0.68.jar
extracted: BOOT-INF/lib/tomcat-embed-el-9.0.68.jar
extracted: BOOT-INF/lib/tomcat-embed-websocket-9.0.68.jar
extracted: BOOT-INF/lib/spring-web-5.3.23.jar
extracted: BOOT-INF/lib/spring-beans-5.3.23.jar
extracted: BOOT-INF/lib/spring-webmvc-5.3.23.jar
extracted: BOOT-INF/lib/spring-aop-5.3.23.jar
extracted: BOOT-INF/lib/spring-context-5.3.23.jar
extracted: BOOT-INF/lib/spring-expression-5.3.23.jar
extracted: BOOT-INF/lib/slf4j-api-1.7.36.jar
extracted: BOOT-INF/lib/spring-core-5.3.23.jar
extracted: BOOT-INF/lib/spring-jcl-5.3.23.jar
extracted: BOOT-INF/lib/spring-boot-jarmode-layertools-2.6.13.jar
 inflated: BOOT-INF/classpath.idx
 inflated: BOOT-INF/layers.idx
root@node01:~/web-app# cat META-INF/MANIFEST.MF 
Manifest-Version: 1.0
Spring-Boot-Classpath-Index: BOOT-INF/classpath.idx
Spring-Boot-Layers-Index: BOOT-INF/layers.idx
Start-Class: com.example.MinWebDemoApplication
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Build-Jdk-Spec: 1.8
Spring-Boot-Version: 2.6.13
Created-By: Maven JAR Plugin 3.3.0
Main-Class: org.springframework.boot.loader.JarLauncher

root@node01:~/web-app# java -jar min-web-demo-0.0.2-SNAPSHOT.jar 

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::               (v2.6.13)

2024-02-15 12:54:39.935  INFO 48664 --- [           main] com.example.MinWebDemoApplication        : Starting MinWebDemoApplication using Java 1.8.0_392 on node01 with PID 48664 (/root/web-app/min-web-demo-0.0.2-SNAPSHOT.jar started by root in /root/web-app)
2024-02-15 12:54:39.937  INFO 48664 --- [           main] com.example.MinWebDemoApplication        : No active profile set, falling back to 1 default profile: "default"
2024-02-15 12:54:40.659  INFO 48664 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2024-02-15 12:54:40.670  INFO 48664 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2024-02-15 12:54:40.670  INFO 48664 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.68]
2024-02-15 12:54:40.725  INFO 48664 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2024-02-15 12:54:40.725  INFO 48664 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 742 ms
2024-02-15 12:54:40.886  INFO 48664 --- [           main] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [static/index.html]
2024-02-15 12:54:40.960  INFO 48664 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2024-02-15 12:54:40.967  INFO 48664 --- [           main] com.example.MinWebDemoApplication        : Started MinWebDemoApplication in 1.343 seconds (JVM running for 1.751)


本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/389013.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【C++】const、static关键字和构造函数初始化

&#x1f497;个人主页&#x1f497; ⭐个人专栏——C学习⭐ &#x1f4ab;点击关注&#x1f929;一起学习C语言&#x1f4af;&#x1f4ab; 目录 1. const修饰成员函数 1.1 语法格式 1.2 权限放大缩小 1.3 思考 1.4 解答 2. 再谈构造函数 2.1 构造函数体赋值 2.2 初始…

用HTML5实现动画

用HTML5实现动画 要在HTML5中实现动画&#xff0c;可以使用以下几种方法&#xff1a;CSS动画、使用<canvas>元素和JavaScript来实现动画、使用JavaScript动画库。重点介绍前两种。 一、CSS动画 CSS3 动画&#xff1a;使用CSS3的动画属性和关键帧&#xff08;keyframes&…

ATT汇编入门[0] hello world

文章目录 写在前面寄存器使用语法指令后缀寻址方式 系统调用示例程序 写在前面 x86汇编有intel和AT&T两种语法&#xff0c;网上资料使用intel语法的相对多一些&#xff0c;但是在linux平台的GNU汇编器用的是AT&T语法&#xff0c;本篇记录一下AT&T格式汇编程序的he…

Kotlin基本语法3集合

1.List集合 1.1 只读List fun main() {val list listOf("Jason", "Jack", "Jacky")println(list.getOrElse(3){"Unknown"})println(list.getOrNull(3)?:"Unknown") } 1.2 可变List fun main() {val mutableList mutabl…

电商+支付双系统项目------设计数据库

这篇文章将详细介绍电商支付双系统项目的数据库设计。数据库在该项目中扮演着至关重要的角色&#xff0c;它负责存储和管理用户信息、商品数据、订单记录以及支付交易等关键数据。通过精心设计和优化数据库结构&#xff0c;可以实现高效的数据存储和检索&#xff0c;确保系统的…

如何查看Apple Watch的步数?这里提供几个方法

所有Apple Watch都配有内置计步器,即具有步进跟踪功能。当你第一次设置手表时,你的Apple Watch将自动开始计算步数。让我们看看如何在Apple Watch上查看步数。​ 使用活动应用程序 1、按下Apple Watch上的数字皇冠,打开应用程序屏幕。 2、点击活动应用程序。 3、你会看到…

书生浦语大模型实战营-课程笔记(3)

本节课主要是跟着教程做的&#xff0c;操作的东西放到作业里记录了。 这里主要记录一些视频里讲的非操作性的东西。 RAG外挂知识库&#xff1f;优点是成本低&#xff0c;不用重新训练 RAG的一个整体流程。 涉及了文本相似度匹配&#xff0c;是不是和传统的问答系统&#xff0…

VueCLI核心知识4:动画效果、过渡效果

1 动画效果 【代码】 <template><div><button click"isShow !isShow">显示/隐藏</button><!-- <transition name"xxx" :appear"true"> 可以指定name属性&#xff0c;也可以不指定&#xff0c;name属性在有…

GAN生成对抗性网络

一、GAN原理 出发点&#xff1a;机器学习中生成模型的问题 无监督学习是机器学习和未来人工智能的突破点&#xff0c;生成模型是无监督学习的关键部分 特点&#xff1a; 不需要MCMC或者变分贝叶斯等复杂的手段&#xff0c;只需要在G和D中对应的多层感知机中运行反向传播或者…

红队打靶练习:HACK ME PLEASE: 1

信息收集 1、arp ┌──(root㉿ru)-[~/kali] └─# arp-scan -l Interface: eth0, type: EN10MB, MAC: 00:0c:29:69:c7:bf, IPv4: 192.168.61.128 Starting arp-scan 1.10.0 with 256 hosts (https://github.com/royhills/arp-scan) 192.168.61.2 00:50:56:f0:df:20 …

[BIZ] - 1.金融交易系统特点

1. 典型数据汇总 数据 说明 新增数据量(条/天) Qps(条/s) 消息大小(Byte) 实时性 可丢失性 可恢复性 实时行情 1.使用场景&#xff1a;交易&#xff0c;报价&#xff0c;策略验证&#xff1b; 2.冷热分离&#xff1a;彭博行情/其他行情&#xff1b;黄金&期货行情/…

Panalog 日志审计系统 libres_syn_delete.php 前台RCE漏洞复现

0x01 产品简介 Panalog是一款日志审计系统,方便用户统一集中监控、管理在网的海量设备。 0x02 漏洞概述 Panalog日志审计系统 libres_syn_delete.php接口处存在远程命令执行漏洞,攻击者可执行任意命令,接管服务器权限。 0x03 影响范围 version <= MARS r10p1Free 0…

【教3妹学编程-算法题】将数组分成最小总代价的子数组 II

2哥 : 叮铃铃&#xff0c;3妹&#xff0c;过年干嘛呢&#xff0c;是不是逛吃逛吃&#xff0c;有没有长胖呢。 3妹&#xff1a;切&#xff0c;我妈张罗着要给我相亲呢。 2哥 : 相亲&#xff1f;哈哈哈哈 3妹&#xff1a;别笑了&#xff0c;我妈说跟我年龄相等的人都已经孩子上小…

iptables防火墙、filter表控制、扩展匹配、使用iptables配置网络型防火墙、NAT原理、配置SNAT

目录 iptables 防火墙filter表 filter中的三条链 环境准备 iptables操作 验证FORWARD链 准备环境 配置FORWARD链 NAT 配置SNAT iptables iptables有多种功能&#xff0c;每一种功能都用一张表来实现最常用的功能是防火墙和NAT从RHEL7开始&#xff0c;默认的防火墙为…

.NET Core WebAPI中使用swagger版本控制,添加注释

一、效果 二、实现步骤 在代码中添加注释 在项目属性中生成API文档 在Program中注册Swagger服务并配置文档信息 // 添加swagger注释 builder.Services.AddSwaggerGen(x > {x.SwaggerDoc("v1", new OpenApiInfo { Title "Swagger标题", Version "…

STM32F1 - 中断系统

Interrupt 1> 硬件框图2> NVIC 中断管理3> EXTI 中断管理3.1> EXTI与NVIC3.2> EXTI内部框图 4> 外部中断实验4.1> 实验概述4.2> 程序设计 5> 总结 1> 硬件框图 NVIC&#xff1a;Nested Vectored Interrupt Controller【嵌套向量中断控制器】 管理…

springboot192中国陕西民俗网

简介 【毕设源码推荐 javaweb 项目】基于springbootvue 的中国陕西民俗网 适用于计算机类毕业设计&#xff0c;课程设计参考与学习用途。仅供学习参考&#xff0c; 不得用于商业或者非法用途&#xff0c;否则&#xff0c;一切后果请用户自负。 看运行截图看 第五章 第四章 获取…

蓝桥杯:C++排列与组合

排列是暴力枚举时的常见操作。有以下两种情况。 C的 next_permutation()是全排列函数&#xff0c;只能输出序列中所有元素的全排列。 本节将给出手写排列和组合的代码。因为在很多场合中不能使用系统自带的排列函数&#xff0c;所以需要自己编写。 全排列函数&#xff1a;nex…

《合成孔径雷达成像算法与实现》Figure6.18

% rho_r c/(2*Fr)而不是rho_r c/(2*Bw) % Hsrcf exp函数里忘记乘pi了 clc clear close all参数设置 距离向参数设置 R_eta_c 20e3; % 景中心斜距 Tr 2.5e-6; % 发射脉冲时宽 Kr 20e12; % 距离向调频率 alpha_os_r 1.2; …

如何使用六图一表七种武器

六图一表七种武器用于质量管理&#xff1a; 描述当遇到问题时应该用那张图来解决&#xff1a; 一、如果题目说出了质量问题需要找原因&#xff1f; 解&#xff1a;用因果图&#xff0c;因果图也称石川图或鱼骨图 二、如果要判断过程是否稳定受控&#xff1f; 解&#xff1a…