728x90

WEB/Spring Boot 12

마이크로미터, 프로메테우스, 그라파나

마이크로미터 소개 앱의 데이터를 측정한 데이터를 API 스펙에 맞게 넘겨줘야할 때 툴을 바꾸게 되면 호환이 맞지 않아서 문제가 된다. 마이크로미터를 통해 하나의 표준방식으로 여러 모니터링툴 구현체를 사용할 수 있게 도와준다. 마이크로미터가 지원하는 툴을 사용해야하긴 하지만 지원하는것들이 엄청 많다. 메트릭 확인하기 미이크로미터에 이미 다양한 지표 수집기능이 만들어져있고 스프링에서는 @AutoConfiguration에서 해당 기능들을 사용할 수 있도록 빈으로 등록한다. actuator/metrics 를 확인하면 jvm.memory.used 처럼 여러 메트릭들이 이미 존재한다. actuator/metrics/jvm.memory.used?tag=area:heap 처럼 tag를 이용하여 한번더 필터링을 할 수 ..

WEB/Spring Boot 2023.05.18

액츄에이터

엔드포인트를 활성화 = 해당 기능자체를 사용할지 말지 on, off 선택하는것 엔드포인트를 노출 = http ,JMX 중 선택 management: info: java: enabled: true os: enabled: true env: enabled: true endpoint: shutdown: enabled: true health: show-components: always endpoints: web: exposure: include: "*" info: app: name: hello-actuator company: yh 굉장히 많은것들이 기본으로 제공이된다. env 의 경우 info.app~ 처럼 info로 시작하게 되면 외부설정으로 인식하여 다 읽어오게 된다. springBoot { buildInfo..

WEB/Spring Boot 2023.05.16

외부설정과 프로필

개발 db와 운영 db url 달라 빌드를 2번해서 배포하는 경우 같은 소스코드에서 나온 빌드 결과물인지 검증하기 어렵다. 빌드는 한번만하고 각 환경에 맞추어 실행 시점에 외부 설정값을 주입하는 방법이 좋다. 빌드를 한번하고 외부 설정을 주입하는 방식 , 새로운 환경이 추가되어도 손쉽게 적용할 수 있다. public class CommandLineBean { private final ApplicationArguments arguments; @PostConstruct public void init() { log.info("source {}", List.of(arguments.getSourceArgs())); log.info("optionNames {}", arguments.getOptionNames());..

WEB/Spring Boot 2023.05.14

스프링 부트 스타터와 라이브러리 관리

plugins { id 'org.springframework.boot' version '3.0.2' id 'io.spring.dependency-management' version '1.1.0' id 'java' } spring boot로 하여금 알아서 라이브러리들의 버전관리를 하기 원하면 io.spring.dependency-management 를 사용하게끔 해야한다. https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-dependencies/build.gradle GitHub - spring-projects/spring-boot: Spring Boot Spring Boot. Contribute ..

WEB/Spring Boot 2023.05.11

스프링 부트와 내장 톰캣

WAR 배포 방식의 단점 애플리케이션 코드를 war로 빌드한 후에 별도로 WAS에 배포하는 과정을 거쳐야한다. 이 과정이 귀찮고 복잡하다. 톰캣도 어차피 자바니까 main()이 실행되는 순간 같이 부팅되게 하고싶다!(톰켓을 라이브러리처럼) == 내장 톰켓기능 탄생 public class EmbedTomcatServletMain { public static void main(String[] args) throws LifecycleException { System.out.println("EmbedTomcatServletMain.main"); // configure tomcat Tomcat tomcat = new Tomcat(); Connector connector = new Connector(); conne..

WEB/Spring Boot 2023.05.10

웹 서버와 서블릿 컨테이너

서블릿 컨테이너 초기화2 (Servelt App 의 유연한 초기화) @HandlesTypes(AppInit.class) public class MyContainerInitV2 implements ServletContainerInitializer { @Override public void onStartup(Set appInitClass: c) { try { AppInit appInit = (AppInit) appInitClass.getDeclaredConstructor().newInstance(); appInit.onStartup(ctx); } catch (Exception e) { throw new RuntimeException(e); } } } } ServletContainer 초기화에서 말고 나만의 ..

WEB/Spring Boot 2023.05.08

외부 설정을 이용한 자동 구성

Environment 추상화와 프로퍼티 imports 를 selector 가 로딩을하고 class level @Conditional 을 확인하고 method level(@Bean을 생성하는 팩토리메소드) 의 @Conditional을 확인하게 된다. custom bean구성정보는 개발자가 추가한 (custom tomcat) 팩토리 빈 메소드를 의미한다. 기본 tomcat port를 바꾸고 싶다든지 다양한 property를 변경을 가능하게 한다. 읽어와서 사용을 할 수 있다. getProperty에 넣는 인자는 다음 사진처럼 4가지로 spring boot가 알아서 converting 해서 인식을 하게 된다. 자동 구성에 Environment 프로퍼티 적용 @MySpringBootApplication publ..

WEB/Spring Boot 2023.02.13
728x90