我在路径xxx/IdeaProjects/xxx/out/artifacts/abc_jar
中创建了一个jar。
当我使用 java -jar 运行它时,我得到
Could not find or load main class ...
我已将 mainfest 文件移至 xxx/IdeaProjects/xxx/src/main/resources/META-INF/MANIFEST.MF
主类是com.rh.xxx.Application
,但仍然得到
Could not find or load main class...
最佳答案
使用完全限定的 java 类在 MANIFEST.MF 文件中设置 Start-Class 属性值。创建 jar 后,在生成的 jar 文件中验证是否相同。
请引用下面,这里的starter类是有main方法的。
META-INF/MANIFEST.MF 的内容
Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: com.mycompany.project.MyApplication
关于java - 使用Intellij生成JAR文件失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45402260/