Spring Boot Admin Server, Client config 설정하기

이미지
 Spring Boot로 많은 프로젝트를 진행하게 됩니다. 많은 모니터링 도구가 있지만, Spring Boot 어플리케이션을 쉽게 모니터링 할 수 있는 방법을 소개하려고 합니다.   코드 중심으로 살펴보겠습니다. 1. 어드민 서버 구축 1-1. 디펜던시 추가 dependencies { // https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-starter-server implementation 'de.codecentric:spring-boot-admin-starter-server:2.5.4' } 1-2. 어드민 서버 설정 활성화 @SpringBootApplication @EnableAdminServer public class ServerApplication { public static void main (String[] args) { SpringApplication. run (ServerApplication. class, args) ; } } EnableAdminServer를 하면 됩니다. 2. 클라이언트 서버 설정  예제는 book-client, member-client 2가지 클라이언트, member-client가 2개의 인스턴스 실행으로 작성했습니다.  2-1 디펜던시 추가 dependencies { // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web implementation 'org.springframework.boot:spring-boot-starter-web:2.5.4' // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-actuator implementation 'org.spring...

intellij lombok 인식 오류 error

  요즘 자바 개발에서 lombok 사용이 거의 필수가 되었습니다. intellij에서 롬복관련 자동완성이 안되고 컴파일 에러(실패)가 발생할 때가 있습니다. 

(사용 버전은 2020.2.4 입니다. 설치가 된 버전도 있습니다.)


기본 예제 클래스
import lombok.Builder;

@Builder
public class Book {

private Integer id;
private String title;
}

컴파일 에러

@Test
public void test() {
Book book = Book.
builder().id(1).title("제목").build();
// 코드 작성
}
테스트 코드를 실행시키면, 실행은 문제없이 됩니다. intellij에서 lombok가 인식되지 못 한 상태인데요.

Window File > Settings (Mac Intellij IDEA > Preferences) 메뉴에서 Plugins를 선택합니다.
롬복 플러그인 설치 방법 이미지

Lombok을 선택하여 설치(install)하고 재시작하면 완료됩니다.

@Test
public void test() {
Book book = Book.builder().id(1).title("제목").build();
// 코드 작성
}
해결된 것을 볼 수 있습니다.

실행이 안될 때

  혹시 실행이 안 되는 경우가 있습니다. 다음과 같이 해결 할 수 있습니다.
어노테이션 프로세싱 활성화 이미지
Build > Compiler > Annotation Processors 메뉴에서 Enable annotation processing을 선택하면 완료


혹시 더 다른 문제나 방법이 있으면 문의 부탁드려요.




댓글

이 블로그의 인기 게시물

Spring boot redis cache config

Spring boot redis RedisTemplate

MySQL PK 중복 (duplicate key ) 해결 방법