原创

【Java】VIM无法编辑jar的解决方式

前言

博客系统进行进行了更新,本来只是为了适应BIng搜索引擎做一点界面的小改动,结果发现我直接使用vim命令,无法编辑。用vim命令编辑后,会显示一个bashj脚本,如下:


### BEGIN INIT INFO
# Provides: xxx
#!/bin/bash
#
# . ____ _ __ _ _
# /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
# ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
# \\/ ___)| |_)| | | | | || (_| | ) ) ) )
# ' |____| .__|_| |_|_| |_\__, | / / / /
# =========|_|==============|___/=/_/_/_/
# :: Spring Boot Startup Script ::
#

### BEGIN INIT INFO
# Provides: xxx
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: xxx
# Description: xxx å<89><8d>å<8f>°ç¨<8b>åº<8f>
# chkconfig: 2345 99 01
### END INIT INFO

[[ -n "$DEBUG" ]] && set -x

# Initialize variables that cannot be provided by a .conf file
WORKING_DIR="$(pwd)"
# shellcheck disable=SC2153
[[ -n "$JARFILE" ]] && jarfile="$JARFILE"
[[ -n "$APP_NAME" ]] && identity="$APP_NAME"

# Follow symlinks to find the real jar and detect init.d script
cd "$(dirname "$0")" || exit 1
[[ -z "$jarfile" ]] && jarfile=$(pwd)/$(basename "$0")
while [[ -L "$jarfile" ]]; do
  if [[ "$jarfile" =~ init\.d ]]; then
    init_script=$(basename "$jarfile")
  else
    configfile="${jarfile%.*}.conf"
    # shellcheck source=/dev/null
    [[ -r ${configfile} ]] && source "${configfile}"
  fi
  jarfile=$(readlink "$jarfile")
  cd "$(dirname "$jarfile")" || exit 1
  jarfile=$(pwd)/$(basename "$jarfile")
done
jarfolder="$( (cd "$(dirname "$jarfile")" && pwd -P) )" cd "$WORKING_DIR" || exit 1 # Inline script specified in build properties

原因分析

首先我环境是已经安装了zip,unzip,gzip这些依赖了

yum install zip unzip gzip

其次,其他的zip文件,我可以直接vim进行编辑。

其实是因为SpringBoot打包的时候配置了executable属性,该属性为true的时候,打包出来的产物可以直接运行,为false的时候,需要使用java -jar xxx.jar运行。

知道原因变更起来就很简单了,修改pom.xml,将<executable>true</executable>,修改为<executable>false</executable>,重新打包即可。

本文来自:【Java】VIM无法编辑jar的解决方式-小码农,转载请保留本条链接,感谢!

温馨提示:
本文最后更新于 2022年10月27日,已超过 544 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我
正文到此结束
本文目录