Visual Studio Code + Spring Boot Project更改spring.properties.additional-location等

问题描述 投票:1回答:1

最近我决定使用pass from Eclipse to VS Code,一切顺利进行Javascript开发但是对于Spring Boot应用程序我不知道如何在这里配置它们。

除了application.properties文件,我有一个额外的local.properties,我用它来本地运行Spring Boot应用程序。

我看到有一个launch.json文件:

{
    "configurations": [

        {
            "type": "java",
            "name": "CodeLens (Launch) - fmApplication",
            "request": "launch",
            "mainClass": "com.application.zz.app.fmApplication",
            "projectName": "file-manager"
        }
    ]
}

在Eclipse中,我添加了额外的配置来运行我的Spring Boot Application,如下所示:

enter image description here

我怎么能这样做是代码:)?

Here is the issue on Vs Code Github Page

spring spring-boot visual-studio-code
1个回答
3
投票

与JavaScript不同,Java代码需要编译,因此它不会与visual studio代码一起开箱即用,因为它只是一个美化的文本编辑器。

然而,有很多工具可以满足这一需求,VS代码的人员可以为您设置一个很好的指南 - https://code.visualstudio.com/docs/java/java-spring-boot


方案:

所以你有一个application.properties文件,在本地你有一个application-local.properties(注意,你必须这样命名你的本地属性)。

然后在你的launch.json中将它添加到你的程序参数:

"args": "--spring.profiles.active=local"

所以你的launch.json文件看起来像这样:

{
  "configurations": [
    {
      "type": "java",
      "name": "CodeLens (Launch) - fmApplication",
      "request": "launch",
      "mainClass": "com.intralot.l10.app.fmApplication",
      "projectName": "file-manager",
      "args": "--spring.profiles.active=local"
    }
  ]
}
© www.soinside.com 2019 - 2024. All rights reserved.