如何在 VS Code 中设置 Kotlin 调试 launch.json 配置?

amo*_*uda 5 kotlin visual-studio-code

我想在从 Java 迁移到 Kotlin 后调试我的 Kotlin Spring boot 应用程序,但是 Kotlin 的 launch.json 具有与 Java 不同的配置,例如我们用于在profiles环境之间切换,当我添加时,"args": "-Dspring.profiles.active=dev"我得到Property args is not allowed. 在调试控制台中我得到

Internal error: java.lang.IllegalArgumentException:    io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.42.Final:compile is not a properly formed Maven/Gradle artifact
[ERROR] java.util.concurrent.CompletionException: java.lang.IllegalArgumentException:    io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.42.Final:compile is not a properly formed Maven/Gradle artifact
Run Code Online (Sandbox Code Playgroud)

这是我当前的 Kotlin 配置:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "kotlin",
            "request": "launch",
            "name": "Kotlin Launch",
            "projectRoot": "${workspaceFolder}",
            "mainClass": "path.to.my.Application",
            "args": "-Dspring.profiles.active=dev" // <--- showing error
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

为了进行比较,这是我的 java launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "Debug (Launch) - Current File",
            "request": "launch",
            "mainClass": "${file}",
            "args": "-Dspring-boot.run.profiles=dev"
        },
        {
            "type": "java",
            "name": "Debug (Launch)",
            "request": "launch",
            "cwd": "${workspaceFolder}",
            "console": "internalConsole",
            "mainClass": "path.to.my.application",
            "projectName": "spring",
            "args": "--spring.profiles.active=dev",
            "vmArgs": "-Dspring.profiles.active=dev"

        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

如果我想使用profilesor , Kotlin 的正确配置是什么args

归档时间:

查看次数:

2233 次

最近记录:

6 年 前