VSCODE에서 환경변수로 실행하기 (feat. spring profile 구분 실행)

최준호·2022년 8월 5일
0

업무

목록 보기
15/31
post-thumbnail

👏 VSCODE에서 환경변수 설정 실행

intellij 에서는 따로 옵션을 편집하는 화면이 제공되어서 간단하게 적용할 수 있었는데 vsc에서도 변수를 설정할 수 있는지 알아보았다.

당연하게도 vsc도 쉽게 설정이 가능했다.

먼저 ctrl+shift+p를 눌러 launch.json를 입력하여 파일을 열자.

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "Launch Current File",
            "request": "launch",
            "mainClass": "${file}"
        },
        {
            "type": "java",
            "name": "Launch ApiTestApplication",
            "request": "launch",
            "mainClass": "com.example.test.ApiTestApplication",
            "projectName": "api-test"
        }
    ]
}

아무런 설정을 하지 않았다면 다음 코드를 확인할 수 있는데 여기에

"args": "옵션"

를 추가해주면 된다. 위치는

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "Launch Current File",
            "request": "launch",
            "mainClass": "${file}"
        },
        {
            "type": "java",
            "name": "Launch ApiTestApplication",
            "request": "launch",
            "mainClass": "com.example.test.ApiTestApplication",
            "projectName": "api-test",
            "args": "--spring.profiles.active=test"
        }
    ]
}

예시로 다음과 같이 profile을 적용시켜주는 값을 넣어줬다. 아주 간단하다

profile
코딩을 깔끔하게 하고 싶어하는 초보 개발자 (편하게 글을 쓰기위해 반말체를 사용하고 있습니다! 양해 부탁드려요!) 현재 KakaoVX 근무중입니다!

0개의 댓글