<html />my-parent |__ my-main (depends on my-other module) |__ my-other
<html />@SpringBootApplication public class MyMainApp ... { ... }
<html />@SpringBootApplication @ConditionalOnProperty(name = "my.other.active", havingValue = "true", matchIfMissing = false) public class MyOtherApp ... { ... }
실행할 어플리케이션 선택 방법
<html />-Dmy.other.active=true -Dspring.profiles.active=$profile
0.1. application yaml을 분리
- 내부 실행 배치
- 외부 DB 접속하는 배치는 장애를 전파할 가능성이 있으니 접속 시스템별 분리
0.2. ComponentScan 을 yaml로 변경
1. yaml을 별도 경로로 분리해서 지정하거나, 여러 yaml을 포함시키는 방법
<html />@SpringBootApplication public class Application { public static final String APPLICATION_LOCATIONS = "spring.config.location=" + "classpath:application.yml" + ",/app/config/springboot-webservice/real-application.yml" ; public static void main(String[] args) { new SpringApplicationBuilder(Application.class) .properties(APPLICATION_LOCATIONS) .run(args); }
classpath : 는 resources 하위의 상대경로에 있는 yaml이 로딩됨
/.../.../ 은 절대 경로로 서버에 배포되는 위치와 일치해야 함
'프로그래밍 > Java-Spring' 카테고리의 다른 글
Java 함수형 프로그래밍 (0) | 2023.01.17 |
---|---|
Java 8 함수형 인터페이스 (Functional Interface) (0) | 2023.01.11 |
5. 와일드카드 타입 <?>, <? extends ...> <? super ...> (0) | 2023.01.11 |
@RequiredArgsConstructor 를 이용한 의존성 주입 (0) | 2022.12.14 |
매개변수 유효성 검사 Objects.requireNonNull() 및 Test 코드 (0) | 2022.12.07 |