Search code examples
javaspring-bootmavenvisual-studio-code

Switch from Eclipse to Visual Studio Code


I would like to switch from Eclipse to Visual Studio Code and start using Microsoft GitHub Copilot.

I'm looking to find the setting related to maven to specify the settings.xml file, cause at the moment it has created a folder "~" in the project folder, and I don't want to have the .m2/repository on each project.

enter image description here

I'm also looking to find where to add the program arguments like --spring.config.import=config/application-backend.yaml --spring.profiles.active=env-local for a spring boot app.


Solution

  • In vscode you can specify the path to settings.xml using the following setting

        // Specifies the absolute path of your maven configuration file, the default value is ~/.m2/settings.xml
        // Replace /path/to/your/settings.xml with the actual path to your settings.xml file.
        "maven.settingsFile": "/path/to/your/settings.xml",
    

    For more settings about it you can search for settings.xml in the Settings panel

    enter image description here

    You can add args configuration to launch.json to add parameters to the program. For example:

    "configurations": [
        {
            "type": "java",
            "name": "Debug (Launch) - YourApplication",
            "request": "launch",
            "mainClass": "com.example.YourApplication",
            "args": [
                "--spring.config.import=config/application-backend.yaml",
                "--spring.profiles.active=env-local"
            ]
        }
    ]
    

    https://code.visualstudio.com/docs/java/java-debugging#_configuration-options