Skip to content

Commit 581762a

Browse files
committed
vscode-spring-boot 1.57 版本打包了 spring-boot-server jar
添加 exploded_ls_jar_data 来区分使用 -jar 启动还是 mainClass 启动
1 parent 995a705 commit 581762a

File tree

2 files changed

+36
-19
lines changed

2 files changed

+36
-19
lines changed

lua/spring_boot/config.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
---@field java_cmd? string The path to the java command.
55
---@field log_file? string|function The path to the spring boot ls log file.
66
---@field server vim.lsp.ClientConfig The language server configuration.
7+
---@field exploded_ls_jar_data boolean The exploded language server jar data.
78

89
---@type bootls.Config
910
local M = {
1011
ls_path = nil,
12+
exploded_ls_jar_data = false,
1113
jdtls_name = "jdtls",
1214
java_cmd = nil,
1315
log_file = nil,

lua/spring_boot/launch.lua

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,44 @@ local function bootls_cmd(rt_dir, java_cmd)
4545
vim.notify("Spring Boot LS is not installed", vim.log.levels.WARN)
4646
return
4747
end
48-
local boot_classpath = {}
49-
table.insert(boot_classpath, boot_path .. "/BOOT-INF/classes")
50-
table.insert(boot_classpath, boot_path .. "/BOOT-INF/lib/*")
48+
if config.exploded_ls_jar_data then
49+
local boot_classpath = {}
50+
table.insert(boot_classpath, boot_path .. "/BOOT-INF/classes")
51+
table.insert(boot_classpath, boot_path .. "/BOOT-INF/lib/*")
5152

52-
local cmd = {
53-
java_cmd or util.java_bin(),
54-
"-XX:TieredStopAtLevel=1",
55-
"-Xmx1G",
56-
"-XX:+UseZGC",
57-
"-cp",
58-
table.concat(boot_classpath, util.is_win and ";" or ":"),
59-
"-Dsts.lsp.client=vscode",
60-
"-Dsts.log.file=" .. logfile(rt_dir),
61-
"-Dspring.config.location=file:" .. boot_path .. "/BOOT-INF/classes/application.properties",
62-
-- "-Dlogging.level.org.springframework=DEBUG",
63-
"org.springframework.ide.vscode.boot.app.BootLanguageServerBootApp",
64-
}
65-
66-
return cmd
53+
local cmd = {
54+
java_cmd or util.java_bin(),
55+
"-XX:TieredStopAtLevel=1",
56+
"-Xmx1G",
57+
"-XX:+UseZGC",
58+
"-cp",
59+
table.concat(boot_classpath, util.is_win and ";" or ":"),
60+
"-Dsts.lsp.client=vscode",
61+
"-Dsts.log.file=" .. logfile(rt_dir),
62+
"-Dspring.config.location=file:" .. boot_path .. "/BOOT-INF/classes/application.properties",
63+
-- "-Dlogging.level.org.springframework=DEBUG",
64+
"org.springframework.ide.vscode.boot.app.BootLanguageServerBootApp",
65+
}
66+
return cmd
67+
else
68+
local server_jar = vim.split(vim.fn.glob(boot_path .. "/spring-boot-language-server*.jar"), "\n")
69+
if #server_jar == 0 then
70+
vim.notify("Spring Boot LS jar not found", vim.log.levels.WARN)
71+
return
72+
end
73+
local cmd = {
74+
java_cmd or util.java_bin(),
75+
"-XX:TieredStopAtLevel=1",
76+
"-Xmx1G",
77+
"-XX:+UseZGC",
78+
"-jar",
79+
server_jar[1],
80+
}
81+
return cmd
82+
end
6783
end
6884

6985
local ls_config = {
70-
-- cmd = bootls_cmd(),
7186
name = "spring-boot",
7287
filetypes = { "java", "yaml", "jproperties" },
7388
-- root_dir = root_dir,

0 commit comments

Comments
 (0)