Maven 无法打包Springboot项目解决方法

news/2024/11/29 8:49:17/

问题1 JAR will be empty - no content was marked…; repackage failed: Unable to find main class

在这里插入图片描述
用生命周期里的东西进行打包而不是插件里面。

jar中没有主清单属性 java -jar xxx-0.0.1-SNAPSHOT.jar 没有主清单属性

在这里插入图片描述

Unable to access jarfile dddl-0.0.1-SNAPSHOT.jar

一般出现这个问题请检查jar包是否在中文路径下与是否在jar所在目录下启动java-jar。

Idea中可运行 到java -jar 不好用报错

Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.example.dddl.demos.web.controller.PostController] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader@6433a2]at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:485)at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321)at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:267)... 61 common frames omitted
Caused by: java.lang.NoClassDefFoundError: com/sun/identity/authentication/spi/AuthLoginExceptionat java.lang.Class.getDeclaredMethods0(Native Method)at java.lang.Class.privateGetDeclaredMethods(Unknown Source)at java.lang.Class.getDeclaredMethods(Unknown Source)at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:467)... 63 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.sun.identity.authentication.spi.AuthLoginExceptionat java.net.URLClassLoader.findClass(Unknown Source)at java.lang.ClassLoader.loadClass(Unknown Source)at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151)at java.lang.ClassLoader.loadClass(Unknown Source)... 67 common frames omittedD:\Desktop>java -jar dddl-0.0.1-SNAPSHOT.jar.   ____          _            __ _ _/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/  ___)| |_)| | | | | || (_| |  ) ) ) )'  |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot ::                (v2.7.6)2024-11-28 19:45:13,950 [ERROR] [main] o.s.b.w.e.t.TomcatStarter - [, , ] - Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'postController': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.example.dddl.demos.web.controller.PostController] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader@6433a2]
2024-11-28 19:45:14,047 [ERROR] [main] o.s.b.SpringApplication - [, , ] - Application run failed
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcatat org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:165)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577)at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)at com.example.dddl.DddlApplication.main(DddlApplication.java:12)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcatat org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:142)at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104)at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:479)at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:211)at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:184)at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:162)... 16 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'postController': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.example.dddl.demos.web.controller.PostController] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader@6433a2]at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:289)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1302)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1219)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213)at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:212)at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:175)at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:170)at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAdaptableBeans(ServletContextInitializerBeans.java:154)at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:87)at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:262)at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:236)at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:53)at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5211)at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1383)at java.util.concurrent.FutureTask.run(Unknown Source)at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835)at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1383)at java.util.concurrent.FutureTask.run(Unknown Source)at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:265)at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)at org.apache.catalina.core.StandardService.startInternal(StandardService.java:430)at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)at org.apache.catalina.startup.Tomcat.start(Tomcat.java:486)at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123)... 21 common frames omitted
Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.example.dddl.demos.web.controller.PostController] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader@6433a2]at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:485)at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321)at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:267)... 61 common frames omitted
Caused by: java.lang.NoClassDefFoundError: com/sun/identity/authentication/spi/AuthLoginExceptionat java.lang.Class.getDeclaredMethods0(Native Method)at java.lang.Class.privateGetDeclaredMethods(Unknown Source)at java.lang.Class.getDeclaredMethods(Unknown Source)at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:467)... 63 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.sun.identity.authentication.spi.AuthLoginExceptionat java.net.URLClassLoader.findClass(Unknown Source)at java.lang.ClassLoader.loadClass(Unknown Source)at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151)at java.lang.ClassLoader.loadClass(Unknown Source)... 67 common frames omitted

原因 :自己外部引用了包 打包时需合并成一个包。
在这里插入图片描述

  <plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>${spring-boot.version}</version><configuration><mainClass>com.example.dddl.DddlApplication</mainClass>
<!--                    <skip>true</skip>--><!--                    将 Scope 为 system 的依赖打包加入--><includeSystemScope>true</includeSystemScope></configuration><executions><execution><id>repackage</id><goals><goal>repackage</goal></goals></execution></executions></plugin>

http://www.ppmy.cn/news/1550858.html

相关文章

2.mybatis整体配置

文章目录 mybatis-config.xml介绍SqlSessionFactoryBuilderXMLConfigBuilderpropertiessetting类型别名&#xff08;typeAliases&#xff09;扫描插件(plugins)解析objectFactory(对象工厂)解析objectWrapperFactory解析reflectorFactorysettingsElement()方法环境配置&#xf…

《C++ Primer Plus》学习笔记|第四章-复合类型 (部分知识)

4.5共用体 union union&#xff0c;也叫联合体&#xff0c;允许在同一段内存位置中存储不同的数据类型&#xff0c;这些不同的数据类型共享同一块内存空间。 共用体的大小为其成员中占用空间最大的成员的大小。 共用体的用途之一是&#xff0c;当数据项使用两种或更多种格式…

模拟手机办卡项目(移动大厅)--结合面向对象、JDBC、MYSQL、dao层模式,使用JAVA控制台实现

目录 1. 项目需求 2. 项目使用的技术 3.项目需求分析 3.1 实体类和接口 4.项目结构 5.业务实现 5.1 登录 5.1.1 实现步骤 5.1.2 原生代码问题 ​编辑 5.1.3 解决方法 1.说明&#xff1a; 2. ResultSetHandler结果集处理 5.1.4 代码 5.1.5 实现后的效果图 登录成功​…

分布式MQTT代理中使用布隆过滤器管理通配符主题

论文标题&#xff1a;Wildcard Topic Management using Bloom Filter in Distributed MQTT Brokers 中文标题&#xff1a;分布式MQTT代理中使用布隆过滤器管理通配符主题 作者信息&#xff1a; Ryohei Banno&#xff0c;Hitotsubashi University, Graduate School of Social…

QT 实现组织树状图

1.实现效果 在Qt中使用QGraphicsItem和QGraphicsScene实现树状图,你需要创建自定义的QGraphicsItem类来表示树的节点,并管理它们的位置和连接,以下是实现效果图。 2.实现思路 可以看见,上图所示,我们需要自定义连线类和节点类。 每个节点类Node,需要绘制矩形框体文字…

告别繁琐剪辑:【星海智算】FunClip重新定义视频创作

FunClip模型介绍 FunClip是由阿里达摩院精心打造的一款完全开源、本地部署的自动化视频剪辑工具。FunClip让用户能够根据识别结果&#xff0c;轻松选择文本片段或特定说话人&#xff0c;从而快速裁剪出所需视频片段。FunClip的特色功能包括集成高精度的中文ASR模型、支持热词定…

讨论JAVA、JVM与Spring

Q1: 作为一个JAVA开发人员&#xff0c;对于jvm肯定不陌生&#xff0c;但很多人对它不陌生也仅止于概念上&#xff0c;而且对概念也是模糊不清的&#xff0c;但jvm实际是java程序运行在其中的实际存在的环境&#xff0c;对它的理解应该要是具象化的。 我们还是从一项技术产生的…

【数据库】macos官网/brew安装mysql5.7/8/9,修改cnf配置/身份验证插件,sqldump数据库备份与恢复

【数据库】macos官网/brew安装mysql5.7/8/9&#xff0c;修改cnf配置/身份验证插件&#xff0c;sqldump数据库备份与恢复 文章目录 1、mysql安装homebrew 安装 mysql9.0官网安装mysql 5.7社区版-归档版 2、修改cnf配置/身份验证方式起因&#xff1a;修改密码验证方式为mysql_nat…