JAVA/Spring(114)
-
[Springboot] 23. SpringApplication #1 Banner, Customizing
SpringApplication의 실행 SpringApplication 클래스는 main() 메서드로부터 시작된 스프링 애플리케이션을 실행시키는 간단한 방법을 제공합니다. 제일 간단한 방법은 다음과 같이 스프링 애플리케이션 실행을 SpringApplication 클래스에게 위임합니다. public static void main(String[] args) { SpringApplication.run(MySpringConfiguration.class, args); } SpringApplication을 실행하면 다음과 같은 결과가 출력됩니다. . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ ..
2022.10.12 -
[Spring] ResourceLoaderAware 인터페이스
1. ResourceLoaderAware 인터페이스는 무엇인가? ResourceLoaderAware 인터페이스는 ResourceLoader 참조가 될 컴포넌트를 식별하는 콜백(callback) 인터페이스입니다. 다음은 ResourceLoaderAware 인터페이스의 정의입니다. public interface ResourceLoaderAware { void setResourceLoader(ResourceLoader resourceLoader); } 한 클래스가 ResourceLoaderAware 인터페이스를 구현하고 ApplicationContext에 배포되면 ApplicationContext에서 ResourceLoaderAware로써 인식됩니다. 그런 다음 ApplicationContext는 setRes..
2022.10.04 -
[Spring] ResourcePatternResolver 인터페이스
1. ResourcePatternResolver 인터페이스는 무엇인가? ResourcePatternResolver 인터페이스는 ResourceLoader 인터페이스를 상속받은 확장판 인터페이스입니다. ResourcePatternResolver 인터페이스의 getResources 메서드는 매개변수로 문자열 타입의 위치 패턴(locationPattern)을 입력받아 해당 패턴에 만족하는 자원들을 가져오는 기능입니다. ApplicationContext 인터페이스는 ResourcePatternResolver 인터페이스를 상속받기 때문에 getResources 메서드를 호출하여 여러 자원들을 가져올 수 있습니다. ResourcePatternResolver 인터페이스 정의 public interface Resour..
2022.10.03 -
[Spring] ResourceLoader 인터페이스
1. ResourceLoader 인터페이스 ResourceLoader 인터페이스는 Resource 인스턴스를 불러올 수 있는 객체에 의해 구현됩니다. 다음은 ResourceLoader 인터페이스의 정의입니다. public interface ResourceLoader { Resource getResource(String location); ClassLoader getClassLoader(); } 모든 ApplicationContext 인터페이스들은 ResourceLoader 인터페이스를 구현하기 때문에 모든 ApplicationContext는 Resource 인스턴스를 얻기 위해 사용할 수 있습니다. 특정 ApplicationContext에서 특정한 접두어를 가지지 않는 위치 경로를 가지고 getResou..
2022.09.30 -
[Spring] Resource 인터페이스와 Resource 인터페이스 구현체
소개 Resource 인터페이스 기존 제공하는 Resource 구현 1. 소개 자바의 표준 java.net.URL 클래스와 다양한 URL 접두어에 대한 표준 핸들러는 불행하게도 모든 로우 레벨 자원들에 대한 접근을 제공하지 않습니다. 예를 들어 클래스패스에서 가져오거나 ServletContext에서 상대적인 경로로 자원에 접근하는데 사용할 수 있는 표준화된 URL 구현이 없습니다. 특수한 url 접두사(http:와 같은 접두사에 대한 기존 핸들러와 유사함)를 위해 새로운 핸들러를 등록하는 것은 가능하지만, 이 방법은 일반적으로 복잡하며 URL 인터페이스는 여전히 접근해야하는 자원의 존재를 확인하는 방법과 같은 기능이 부족합니다. 2. Resource 인터페이스 "org.springframework.cor..
2022.09.25 -
[Spring][IoC] ApplicationEventPublisher
ApplicationEventPublisher란 무엇인가? ApplicationEventPublisher 인터페이스는 이벤트 프로그래밍에 필요한 이벤트를 제공하고 옵저버 패턴의 구현체입니다. ApplicationContext 클래스는 ApplicationEventPublisher를 상속받고 있습니다. ApplicationEventPublisher를 상속받은 ApplicationContext 클래스는 publishEvent(ApplicationEvent) 메서드를 호출하여 이벤트를 발생시킬 수 있습니다. 1. 이벤트 생성 ApplicationEvent 클래스를 상속받은 이벤트를 생성합니다. 여기서 source는 이벤트가 시작된 객체를 의미하고 data 변수는 이벤트 발생시 같이 보내고자 하는 데이터입니다...
2022.09.23