[英]How can I set in vscode a default java configuration in launch.json to make vscode stop asking me to specify a main class every time I run the app?
every time I start my Java application, vscode asks me to specify the main Class for my java configuration, even though I already did it in launch.json.每次我启动我的 Java 应用程序时,vscode 都会要求我为我的 Java 配置指定主类,即使我已经在 launch.json 中这样做了。 bit i believe what it's asking me is to choose a certain configuration to run from.
我相信它要求我选择某种配置来运行。 so my question is:
所以我的问题是:
is there a way to make a default Configuration to run from in launch.json?有没有办法让默认配置从launch.json中运行?
this is my launch.json:这是我的launch.json:
"configurations": [
{
"type": "java",
"name": "admin-ui",
"request": "launch",
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"mainClass": "com.bla.blo.Application",
"projectName": "admin-ui",
If a class is kind of public
and includes the function public static void main(String[] args)
, java extension will recognize it as mainClass and auto-complete it in launch.json.如果一个类是
public
类并且包含函数public static void main(String[] args)
,java 扩展会将其识别为mainClass并在 launch.json 中自动完成它。
About you saying:关于你说:
vscode asks me to specify the main Class for my java configuration
vscode 要求我为我的 java 配置指定主类
It's may because when your debugging option is Current File ,you have more than one mainclass, so java extension will ask you to select one to run:这可能是因为当你的调试选项是Current File 时,你有多个主类,所以 java 扩展会要求你选择一个来运行:
Anyway, the solution is selecting the option which name
is in mainClass
configuration from the debug drop-down box on the left.无论如何,解决方案是从左侧的调试下拉框中选择
name
在mainClass
配置中的选项。 From the configuration in your launch.json, you should choose admin-ui .从 launch.json 中的配置中,您应该选择admin-ui 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.