在Spring-Tools-suite(eclipse的定制版本)中,有一个选项可以为同一应用程序定义多个运行配置,然后运行它们。
例如,在测试Eureka Server并使用不同的端口和名称定义运行同一应用程序的多个实例以检查注册时。
是否有人知道使用带有Visual Studio Code的Spring和Java Extensions定义类似运行配置的方法?
答案 0 :(得分:6)
直接回答您的问题,您可能需要的功能是:
Debugging with Launch Configurations
要在VS Code中调试一个简单的应用程序,请按F5键,VS Code将尝试调试您当前处于活动状态的文件。
但是,对于大多数调试方案而言,创建启动配置文件很有用,因为它使您可以配置和保存调试设置详细信息。
有关该功能的文档很多。就像在Eclipse中一样,它是与调试相关的(在Eclipse中启动应用程序不一定要附加到调试器)。您将最熟悉类似于运行配置的启动配置(而不是附加)。 Add a new configuration说明了如何通过摘要而不是像Eclipse那样通过向导来构建Sub Reshuffle()
Dim Arr As Variant, FreqArr As Variant, Place As Long, Comp1 As Variant, Comp2 As Variant
Dim rngArr As Range, i As Long, j As Long, k As Long, ListB1 As MSForms.ListBox, ListB2 As MSForms.ListBox
Set ListB1 = CreateObject("New:{8BD21D20-EC42-11CE-9E0D-00AA006002F3}")
Set ListB2 = CreateObject("New:{8BD21D20-EC42-11CE-9E0D-00AA006002F3}")
Set rngArr = Range("A2:B12")
With ListB1
.Column = Application.Transpose(rngArr)
ListB2.List = .List
For i = LBound(.List) To UBound(.List)
Arr = Application.Match(Application.Transpose(Application.Index(.List, 0, 1)), Application.Index(.List, 0, 1), 0)
FreqArr = Application.Frequency(Arr, Arr)
If Application.Max(FreqArr) > (UBound(.List) + 2) / 2 Then MsgBox "not possible"
For j = 1 To UBound(.List) + 1
Place = Application.Match(Application.Large(FreqArr, j), FreqArr, 0)
Comp2 = .List(Place - 1, 0)
If Comp2 <> Comp1 Then Exit For
Next j
Comp1 = Comp2
With ListB2
For k = LBound(.List, 2) To UBound(.List, 2)
.List(i, k) = ListB1.List(Place - 1, k)
Next k
ListB1.RemoveItem Place - 1
End With
Next i
End With
rngArr.Value = ListB2.List 'replaces in same range
Set ListB1 = Nothing
Set ListB2 = Nothing
End Sub
文件。
特别是关于Spring Boot,Pivotal为您提供了几个扩展:Spring Boot Tools和Spring Initializr support,为您提供了Launches的一些额外功能。
运行配置和启动配置很合适,但是正如Leo Zhu在评论中提到的那样,Maven配置文件(Configure active profile in SpringBoot via Maven / docs)或Gradle等效使用launch.json
语句控制环境(Maven profiles equivalent of Gradle / Gradle blog entry)的移植性更强,并且与IDE无关。这些方法属于我个人投票。
答案 1 :(得分:0)
我使用 Java-1.8.0_231-b11
在 VSCode-1.40.2 中对此进行了测试您将需要以下内容来启动 launch.json : https://code.visualstudio.com/docs/java/java-debugging
对于STS开发,您可以从以下网址下载: https://marketplace.visualstudio.com/items?itemName=Pivotal.vscode-boot-dev-pack
这是我的 launch.json 设置,用于生成使用VSCode开发的微服务的两个实例。 请注意我如何在 vmArgs 中设置服务器端口以在 8000和8001
上使用{
"configurations": [
{
"type": "java",
"name": "CodeLens (Launch-8000) - CurrencyExchangeServiceApplication",
"request": "launch",
"mainClass": "com.microservices.currencyexchangeservice.CurrencyExchangeServiceApplication",
"projectName": "currency-exchange-service",
"vmArgs": "-Dserver.port=8000"
},
{
"type": "java",
"name": "CodeLens (Launch-8001) - CurrencyExchangeServiceApplication",
"request": "launch",
"mainClass": "com.microservices.currencyexchangeservice.CurrencyExchangeServiceApplication",
"projectName": "currency-exchange-service",
"vmArgs": "-Dserver.port=8001"
}
]
}
希望这会有所帮助。