spring boot项目,构建为可执行jar,但我发现无法提取可执行jar,例如
jar xvf spring-boot-foo-0.0.1-SNAPSHOT.jar
Run Code Online (Sandbox Code Playgroud)
没什么输出.但是当提取一个普通的罐子时,它是成功的
jar xvf mysql-connector-java-5.1.38.jar
created: META-INF/
inflated: META-INF/MANIFEST.MF
created: META-INF/services/
...
Run Code Online (Sandbox Code Playgroud)
为什么是这样?
小智 20
您可以less在jar文件中找到以下内容:
#!/bin/bash
#
# . ____ _ __ _ _
# /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
# ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
# \\/ ___)| |_)| | | | | || (_| | ) ) ) )
# ' |____| .__|_| |_|_| |_\__, | / / / /
# =========|_|==============|___/=/_/_/_/
# :: Spring Boot Startup Script ::
#
Run Code Online (Sandbox Code Playgroud)
也就是说,它是一个bash文件跟随一个jar,而不是一个普通的jar.
你可以提取这个文件使用: unzip spring-boot-foo-0.0.1-SNAPSHOT.jar
或者将spring-boot-maven-plugin的可执行标志设置为false以生成普通的jar文件.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>false</executable>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
小智 11
使用 7zip 打开 Springboot 可执行 jar 时,您需要右键单击 .jar 文件并选择第二个 7zip 选项“打开存档...”,然后从其他格式中选择 zip 作为格式。选择“作为存档打开”将不起作用。
小智 9
我通常使用7zip来提取Windows上的文件,它也不起作用.感谢@ peace0phmind,我尝试用我的文本编辑器(记事本++)打开它,我看到内容是一个shell脚本,后跟二进制代码.
我刚刚删除了所有bash脚本行,保存了文件,现在我可以用7zip打开它.
| 归档时间: |
|
| 查看次数: |
6077 次 |
| 最近记录: |