Skip to content

加密后启动提示找不到main class #145

Description

@dwj1979

开发环境:Java 17+springboot4.0
加密后提示:
错误: 找不到或无法加载主类 null
原因: java.lang.ClassNotFoundException: null
panic: exit status 1

goroutine 1 [running]:
main.main()
D:/Projects/testaot/target/xjar.go:87 +0x46c

打开xjar文件在META-INF\MANIFEST.MF文件中发现Main-Class被设为了null
Manifest-Version: 1.0
Created-By: Maven JAR Plugin 3.4.2
Build-Jdk-Spec: 17
Implementation-Title: testaot
Implementation-Version: 0.0.1-SNAPSHOT
Main-Class: null
Start-Class: com.pxy.testaot.TestaopApplication
Spring-Boot-Version: 4.0.0-SNAPSHOT
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Spring-Boot-Classpath-Index: BOOT-INF/classpath.idx
Spring-Boot-Layers-Index: BOOT-INF/layers.idx
Boot-Main-Class: org.springframework.boot.loader.launch.JarLauncher

我看查看最新代码: io/xjar/boot/XBootEncryptor.java,用到map.get(mainClass),但map中并没有设置mainClass的值。
// META-INF/MANIFEST.MF
else if (entry.getName().equals(META_INF_MANIFEST)) {
manifest = new Manifest(nis);
Attributes attributes = manifest.getMainAttributes();
String mainClass = attributes.getValue("Main-Class");
if (mainClass != null) {
attributes.putValue("Boot-Main-Class", mainClass);
attributes.putValue("Main-Class", map.get(mainClass));
}

请麻烦确认一下是xjar代码问题,还是我使用有问题。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions