실제 현업에서 application.properties 설정 파일은 resources 하위에 real, develop, stage 3개의 세팅으로 실행하고 있었다.
그래서 전부 spring.profiles.active 설정이 각각 본인으로 되어 있길래, 어떻게 실행을 하면 real로 바로 돌아가는지 궁금했다.
public static void main(String[] args) {
String profile = System.getProperty("spring.profiles.active");
if(profile == null) {
System.setProperty("spring.profiles.active", "develop");
}
SpringApplication.run(AdminApplication.class, args);
}
이런 식으로 메인에서 직접 세팅을 하고 돌리면 된다.
근데 만약 이래도 다른 설정파일이 돌아간다면!!!
인텔리제이 상단에 Run > Edit Configurations > Environment 하위에서 Vm Options 안에 넣어줘야 한다.
-Dspring.profiles.active=develop 이런 식으로 내가 돌리고자 하는 active를 입력해서 실행하면 해당 설정파일로 실행하게 된다.
이렇게 해서 원하는 설정파일을 돌리면 된다!!!