분류 전체보기

💐 Spring/Spring 핵심 기술

9. IoC 컨테이너 8부 : ApplicationEventPublisher

이벤트 프로그래밍에 필요한 인터페이스 제공. 옵저버 패턴 구현체 ApplicationContext extends ApplicationEventPublisher publishEvent(ApplicationEvent event) [event 처리 과정] SpringBootApplication이 구동 -> AppRunner가 실행이 되면서 -> event 발생! -> 발생한 event를 등록되어있는 빈 중에서 MyEvent가 받아서 처리. 이벤트 발생 시키는 방법 - ApplicationEventPublisher.publishEvent(); @Component public class AppRunner implements ApplicationRunner { @Autowired ApplicationContext ..

💐 Spring/Spring 핵심 기술

8. IoC 컨테이너 7부 : MessageSource

국제화 (i18n) 기능을 제공하는 인터페이스. ApplicationContext extends MessageSource getMessage(String code, Object[] args, String, default, Locale, loc) ... 스프링 부트를 사용한다면 별다른 설정 필요없이 messages.properties 사용할 수 있음 messages.properties messages_ko_kr.properties ... @Component public class AppRunner implements ApplicationRunner { @Autowired MessageSource messageSource; @Override public void run(ApplicationArguments ..

💐 Spring/Spring 핵심 기술

7. IoC 컨테이너 6부 : Environment 2부. 프로퍼티

프로퍼티 다양한 방법으로 정의할 수 있는 설정값 Environment의 역할은 프로퍼티 소스 설정 및 프로퍼티 값 가져오기 1) 다양한 방법으로 정의할 수 있는 설정값 1-1. VM options 설정 VM options : -Dapp.name=spring5 설정 @Component public class AppRunner implements ApplicationRunner { @Autowired ApplicationContext ctx; @Autowired BookRepository bookRepository; @Override public void run(ApplicationArguments args) throws Exception { Environment environment = ctx.getEnv..

🌻 JAVA/정리정리정리

[Java] isNumeric(String s) 메소드

public static boolean isNumeric(String s) { try { Double.parseDouble(s); return true; } catch(NumberFormatException e) { return false; } } String s ; boolean chk = isNumeric( s );

🌻 JAVA/정리정리정리

[Java] ArrayList 사용법

ArrayList란? ArrayList는 List 인터페이스를 상속받은 클래스로 크기가 가변적으로 변하는 선형리스트입니다. 1. 한번 생성되면 크기가 변하지 않는 배열과는 달리 ArrayList는 객체들이 추가되어 저장 용량(capacity)을 초과한다면 자동으로 부족한 크기만큼 저장 용량(capacity)이 늘어난다는 특징을 가지고 있습니다. ArrayList 선언 import java.util.ArrayList; ArrayList list = new ArrayList();//타입 미설정 Object로 선언된다. ArrayList members = new ArrayList();//타입설정 Student객체만 사용가능 ArrayList num = new ArrayList();//타입설정 int타입만 사용..

💐 Spring/Spring 핵심 기술

6. IoC 컨테이너 6부 : Environment 1부. 프로파일

Environment 프로파일과 프로퍼티를 다루는 인터페이스 ApplicationContext extends EnvironmentCapable getEnvironment() Environment EnvironmentCapable 프로파일 빈들의 그룹 Environment의 역할은 활성화할 프로파일 확인 및 설정 프로파일 유즈케이스 테스트 환경에서는 A라는 빈을 사용하고, 배포 환경에서는 B라는 빈을 쓰고 싶은 경우! 이 빈은 모니터링 용도니까 테스트할 때는 필요가 없고 배포할 때만 등록이 되면 좋겠다! 1. 각각의 환경에 따라.. 다른 빈들을 써야하는 경우! 2. 특정 환경에서만 어떤 빈을 등록하는 경우 프로파일 정의하기 클래스에 정의 @Configuration @Profile("test") @Compo..