记录一次idea打包启动失败 nested exception is javax.persistence.PersistenceException: Unable to resolve persistence unit root
idea打包流程
file->Project Structure…->Artifacts->点击+符号->JAR->From moudles with dependencies…

1、红色圈需要选择工程启动文件(包含mian方法文件)
2、推荐勾选copy to the output directory and link via manifest,选择该项,执行jar出错起码会有些提示,选择打包成一个jar包,出错则基本上就只会提示找不到主类。。。
3、Directory for META-INF/MANIFEST.MF:
选择一个放置META-INF文件夹位置,选择放在项目src/main/resources文件下,切记,非默认值。
4、OK按钮

这个界面Output directory:选择一个jar输出的文件夹即可,点击ok。
最后一步:Build->Build Artifacts…->Build或者ReBuild。到输出jar包目录下打开cmd:java -jar xxx.jar。
出现 nested exception is javax.persistence.PersistenceException: Unable to resolve persistence unit root
将pom文件中的
<dependency>
-
<groupId>org.springframework.boot</groupId> -
<artifactId>spring-boot-starter-data-jpa</artifactId> -
</dependency>
删除,出现这种情况。一般都是pom文件有问题,删除重复、多余的dependency,降低spring-boot-starter-parent版本为2.1.0都是可以尝试的。
在使用IDEA进行项目打包时,遇到了`nested exception is javax.persistence.PersistenceException: Unable to resolve persistence unit root`的问题。解决方法包括检查工程启动文件的选择,确保包含main方法,设置`copy to the output directory and link via manifest`,调整META-INF目录位置,以及检查pom.xml文件中是否有重复或多余的dependency,考虑降低spring-boot-starter-parent版本。
4408

被折叠的 条评论
为什么被折叠?



