[运行报错] 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.jarroot@node01:~/web-app# jar -xvf min-web-demo-0.0.1-SNAPSHOT.jar created: META-INF/inflated: META-INF/MANIFEST.MFcreated: 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.propertiesinflated: com/example/demos/web/BasicController.classinflated: com/example/demos/web/PathVariableController.classinflated: com/example/demos/web/User.classinflated: com/example/MinWebDemoApplication.classinflated: static/index.htmlinflated: META-INF/maven/com.example/min-web-demo/pom.xmlinflated: 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.0root@node01:~/web-app# jar -xvf min-web-demo-0.0.2-SNAPSHOT.jar created: META-INF/inflated: META-INF/MANIFEST.MFcreated: org/created: org/springframework/created: org/springframework/boot/created: org/springframework/boot/loader/inflated: org/springframework/boot/loader/ClassPathIndexFile.classinflated: org/springframework/boot/loader/ExecutableArchiveLauncher.classinflated: org/springframework/boot/loader/JarLauncher.classinflated: org/springframework/boot/loader/LaunchedURLClassLoader$DefinePackageCallType.classinflated: org/springframework/boot/loader/LaunchedURLClassLoader$UseFastConnectionExceptionsEnumeration.classinflated: org/springframework/boot/loader/LaunchedURLClassLoader.classinflated: org/springframework/boot/loader/Launcher.classinflated: org/springframework/boot/loader/MainMethodRunner.classinflated: org/springframework/boot/loader/PropertiesLauncher$1.classinflated: org/springframework/boot/loader/PropertiesLauncher$ArchiveEntryFilter.classinflated: org/springframework/boot/loader/PropertiesLauncher$ClassPathArchives.classinflated: org/springframework/boot/loader/PropertiesLauncher$PrefixMatchingArchiveFilter.classinflated: org/springframework/boot/loader/PropertiesLauncher.classinflated: org/springframework/boot/loader/WarLauncher.classcreated: org/springframework/boot/loader/archive/inflated: org/springframework/boot/loader/archive/Archive$Entry.classinflated: org/springframework/boot/loader/archive/Archive$EntryFilter.classinflated: org/springframework/boot/loader/archive/Archive.classinflated: org/springframework/boot/loader/archive/ExplodedArchive$AbstractIterator.classinflated: org/springframework/boot/loader/archive/ExplodedArchive$ArchiveIterator.classinflated: org/springframework/boot/loader/archive/ExplodedArchive$EntryIterator.classinflated: org/springframework/boot/loader/archive/ExplodedArchive$FileEntry.classinflated: org/springframework/boot/loader/archive/ExplodedArchive$SimpleJarFileArchive.classinflated: org/springframework/boot/loader/archive/ExplodedArchive.classinflated: org/springframework/boot/loader/archive/JarFileArchive$AbstractIterator.classinflated: org/springframework/boot/loader/archive/JarFileArchive$EntryIterator.classinflated: org/springframework/boot/loader/archive/JarFileArchive$JarFileEntry.classinflated: org/springframework/boot/loader/archive/JarFileArchive$NestedArchiveIterator.classinflated: org/springframework/boot/loader/archive/JarFileArchive.classcreated: org/springframework/boot/loader/data/inflated: org/springframework/boot/loader/data/RandomAccessData.classinflated: org/springframework/boot/loader/data/RandomAccessDataFile$1.classinflated: org/springframework/boot/loader/data/RandomAccessDataFile$DataInputStream.classinflated: org/springframework/boot/loader/data/RandomAccessDataFile$FileAccess.classinflated: org/springframework/boot/loader/data/RandomAccessDataFile.classcreated: org/springframework/boot/loader/jar/inflated: org/springframework/boot/loader/jar/AbstractJarFile$JarFileType.classinflated: org/springframework/boot/loader/jar/AbstractJarFile.classinflated: org/springframework/boot/loader/jar/AsciiBytes.classinflated: org/springframework/boot/loader/jar/Bytes.classinflated: org/springframework/boot/loader/jar/CentralDirectoryEndRecord$1.classinflated: org/springframework/boot/loader/jar/CentralDirectoryEndRecord$Zip64End.classinflated: org/springframework/boot/loader/jar/CentralDirectoryEndRecord$Zip64Locator.classinflated: org/springframework/boot/loader/jar/CentralDirectoryEndRecord.classinflated: org/springframework/boot/loader/jar/CentralDirectoryFileHeader.classinflated: org/springframework/boot/loader/jar/CentralDirectoryParser.classinflated: org/springframework/boot/loader/jar/CentralDirectoryVisitor.classinflated: org/springframework/boot/loader/jar/FileHeader.classinflated: org/springframework/boot/loader/jar/Handler.classinflated: org/springframework/boot/loader/jar/JarEntry.classinflated: org/springframework/boot/loader/jar/JarEntryCertification.classinflated: org/springframework/boot/loader/jar/JarEntryFilter.classinflated: org/springframework/boot/loader/jar/JarFile$1.classinflated: org/springframework/boot/loader/jar/JarFile$JarEntryEnumeration.classinflated: org/springframework/boot/loader/jar/JarFile.classinflated: org/springframework/boot/loader/jar/JarFileEntries$1.classinflated: org/springframework/boot/loader/jar/JarFileEntries$EntryIterator.classinflated: org/springframework/boot/loader/jar/JarFileEntries$Offsets.classinflated: org/springframework/boot/loader/jar/JarFileEntries$Zip64Offsets.classinflated: org/springframework/boot/loader/jar/JarFileEntries$ZipOffsets.classinflated: org/springframework/boot/loader/jar/JarFileEntries.classinflated: org/springframework/boot/loader/jar/JarFileWrapper.classinflated: org/springframework/boot/loader/jar/JarURLConnection$1.classinflated: org/springframework/boot/loader/jar/JarURLConnection$JarEntryName.classinflated: org/springframework/boot/loader/jar/JarURLConnection.classinflated: org/springframework/boot/loader/jar/StringSequence.classinflated: org/springframework/boot/loader/jar/ZipInflaterInputStream.classcreated: org/springframework/boot/loader/jarmode/inflated: org/springframework/boot/loader/jarmode/JarMode.classinflated: org/springframework/boot/loader/jarmode/JarModeLauncher.classinflated: org/springframework/boot/loader/jarmode/TestJarMode.classcreated: org/springframework/boot/loader/util/inflated: org/springframework/boot/loader/util/SystemPropertyUtils.classcreated: 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.propertiesinflated: BOOT-INF/classes/com/example/demos/web/BasicController.classinflated: BOOT-INF/classes/com/example/demos/web/PathVariableController.classinflated: BOOT-INF/classes/com/example/demos/web/User.classinflated: BOOT-INF/classes/com/example/MinWebDemoApplication.classinflated: BOOT-INF/classes/static/index.htmlinflated: META-INF/maven/com.example/min-web-demo/pom.xmlinflated: META-INF/maven/com.example/min-web-demo/pom.propertiescreated: 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.jarinflated: BOOT-INF/classpath.idxinflated: 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.JarLauncherroot@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.mzph.cn/news/684711.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

C++数据结构与算法——字符串

C第二阶段——数据结构和算法&#xff0c;之前学过一点点数据结构&#xff0c;当时是基于Python来学习的&#xff0c;现在基于C查漏补缺&#xff0c;尤其是树的部分。这一部分计划一个月&#xff0c;主要利用代码随想录来学习&#xff0c;刷题使用力扣网站&#xff0c;不定时更…

2024年【危险化学品经营单位安全管理人员】免费试题及危险化学品经营单位安全管理人员考试总结

题库来源&#xff1a;安全生产模拟考试一点通公众号小程序 危险化学品经营单位安全管理人员免费试题参考答案及危险化学品经营单位安全管理人员考试试题解析是安全生产模拟考试一点通题库老师及危险化学品经营单位安全管理人员操作证已考过的学员汇总&#xff0c;相对有效帮助…

WordPress作者页面链接的用户名自动变成16位字符串串插件Smart User Slug Hider

WordPress默认的作者页面URL链接地址格式为“你的域名/author/admin”&#xff0c;其中admin就是你的用户名&#xff0c;这样的话就会暴露我们的用户名。 为了解决这个问题&#xff0c;前面boke112百科跟大家分享了『如何将WordPress作者存档链接中的用户名改为昵称或ID』一文…

Linux进程间通信(二)-----system V共享内存

共享内存的概念 共享内存让不同进程看到同一份资源的方式就是&#xff0c;在物理内存当中申请一块内存空间&#xff0c;然后将这块内存空间分别与各个进程各自的页表之间建立映射&#xff0c;再在虚拟地址空间当中开辟空间并将虚拟地址填充到各自页表的对应位置&#xff0c;使得…

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

下载sentence_transformer的代码运行情况。sentence_transformer用于embedding&#xff08;转向量&#xff09; 本地构建持久化向量数据库。就是把txt和md文件抽取出纯文本&#xff0c;分割成定长&#xff08;500&#xff09;后转换成向量&#xff0c;保存到本地&#xff0c;称…

Python算法题集_二叉树的层序遍历

Python算法题集_二叉树的层序遍历 题102&#xff1a;二叉树的层序遍历1. 示例说明2. 题目解析- 题意分解- 优化思路- 测量工具 3. 代码展开1) 标准求解【DFS递归】2) 改进版一【BFS迭代】3) 改进版二【BFS迭代循环】 4. 最优算法 本文为Python算法题集之一的代码示例 题102&am…

python 人脸检测器

import cv2# 加载人脸检测器 关键文件 haarcascade_frontalface_default.xml face_cascade cv2.CascadeClassifier(haarcascade_frontalface_default.xml)# 读取图像 分析图片 ren4.png image cv2.imread(ren4.png) gray cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)# 进行人脸…

C++虚函数

C虚函数 在C中&#xff0c;虚函数&#xff08;Virtual Function&#xff09;是一个使用关键字virtual声明的成员函数&#xff0c;它在基类中被声明&#xff0c;以便在任何派生类中被重写&#xff08;Override&#xff09;。使用虚函数的目的是实现多态性——一种允许使用基类指…

C#(C Sharp)学习笔记_编程练习题 _输出奇偶数, 九九乘法表, 猜数字游戏【八】

1. 输出奇偶数 要求&#xff1a;输出从1到100的所有偶数 分析&#xff1a; 首先我们需要用到循环&#xff08;while也好&#xff0c;for也好&#xff0c;但for会更加优雅&#xff09;&#xff0c;输出0到100的所以数。在for的循环体内写入if条件判断语句&#xff0c;条件表达…

数据密集型应用系统设计

数据密集型应用系统设计 原文完整版PDF&#xff1a;https://pan.quark.cn/s/d5a34151fee9 这本书的作者是少有的从工业界干到学术界的牛人&#xff0c;知识面广得惊人&#xff0c;也善于举一反三&#xff0c;知识之间互相关联&#xff0c;比如有个地方把读路径比作programming …

ESP32学习(4)——电脑远程控制LED灯

1.思路梳理 首先需要让ESP32连接上WIFI 然后创建udp socket 接着接收udp数据 最后解析数据&#xff0c;控制LED 2.代码实现 import network from socket import * from machine import Pin p2Pin(2,Pin.OUT)def do_connect(): #连接wifi wlan network.WLAN(network.STA_IF)…

MySQL性能调优篇(8)-NoSQL与MySQL的比较

MySQL数据库是一种关系型数据库&#xff0c;而NoSQL是一种非关系型数据库。它们在数据存储和处理方式、数据模型和可扩展性等方面存在一些明显的差异。本文将对MySQL数据库和NoSQL进行比较&#xff0c;并介绍它们的优势和劣势。 首先&#xff0c;MySQL使用表格的形式来存储数据…

122.乐理基础-五线谱-音程、度数、根音、冠音

内容参考于&#xff1a;三分钟音乐社 上一个内容&#xff1a;五线谱的临时变音记号规则 上一个内容里练习的答案&#xff1a; 1-121看完就可以认识乐谱、熟悉乐谱了&#xff0c;从现在开始与识谱无关&#xff0c;与创作有关 参考图&#xff1a;音程与和弦只是为了撬开去往和…

Vue2学习第一天

Vue2 学习第一天 1. 什么是 vue? Vue 是一套用于构建用户界面的渐进式框架。 2. vue 历史 vue 是在 2013 年创建的&#xff0c;vue3 是 2020 出现的&#xff0c;现在主要是用 vue2&#xff0c;创新公司用的是 vue3 vue 的作者是尤雨溪&#xff0c;vue 的搜索热度比 react…

jacob使用教程---OFFICE操作几乎万能公式---读写XML

参考资料: jacob的GitHub地址https://github.com/freemansoft/jacob-project jacob官网(个人感觉不重要)https://danadler.com/tech-articles/jacob-2/ microsoft官方VBA文档(很重要,jacob所有的参数都来自于这里)https://learn.microsoft.com/zh-cn/office/vba/api/o…

多线程的基本原理学习

由一个问题引发的思考 线程的合理使用能够提升程序的处理性能&#xff0c;主要有两个方面&#xff0c;第一个是能够利用多核cpu以及超线程技术来实现线程的并行执行&#xff1b;第二个是线程的异步化执行相比于同步执行来说&#xff0c;异步执行能够很好的优化程序的处理性能提…

【Day42】代码随想录之动态规划0-1背包_416. 分割等和子集

文章目录 动态规划理论基础动规五部曲&#xff1a;出现结果不正确&#xff1a; 416. 分割等和子集 动态规划理论基础 动规五部曲&#xff1a; 确定dp数组 下标及dp[i] 的含义。递推公式&#xff1a;比如斐波那契数列 dp[i] dp[i-1] dp[i-2]。初始化dp数组。确定遍历顺序&am…

【JAVA-Day87】线程终止问题

线程终止问题 线程终止问题&#xff0c;什么情况下需要终止线程&#xff0c;如何终止Java线程&#xff1f;摘要引言1. 理解线程终止&#xff1a;它代表什么&#xff1f;&#x1f6d1;线程终止的方式线程终止的含义注意事项示例代码 2. 何时需要终止线程&#xff1f;&#x1f91…

新机Word/PowerPoint新建空白文档后闪退问题

首先可以尝试一下常规的修复&#xff1a; 设置-应用-安装的应用-搜索office-点击Micros Office Home and Student...右侧三个点-选择修改-点击是-快速修复-修复 再不行就按上面的选择联机修复&#xff0c;这个会卸载现有Office然后自动帮你重新下载 我做了以上两个都没有解决问…

2024年华为OD机试真题-万能字符单词拼写 -Python-OD统一考试(C卷)

题目描述: 有一个字符串数组words和一个字符串chars。 假如可以用chars中的字母拼写出words中的某个“单词”(字符串),那么我们就认为你掌握了这个单词。 words的字符仅由 a-z 英文小写字母组成。 例如: abc chars 由 a-z 英文小写字母和 “?”组成。其中英文问号“?”表…