ioc 3

[Spring] IoC 컨테이너 사용하기 - XML Config

❑ IoC 컨테이너 사용하기 Spring Bean Configuration을 읽어객체를 생성하고 조립해주는 Spring의 구체적 객체는 ApplicationContext(Interface) 다. SpringConfig를 넘기는 방식에 따라 4가지로 분류된다 ClassPathxmlApplicationContenxt: Application의 root부터 경로를 지정할 때 (대표적인 구현체) FileSystemXmlApplicationContenxt: xml 파일의 directory 경로 XmlWebApplicationContenxt: SpringConfig.xml을 웹에 등록해서 사용 AnnotationConfigApplicationContenxt: Annotation을 스캔하는 방식으로 사용 아래 예제를..

Back-End/Spring 2021.08.19

[Spring] 값(Value) 주입 설정 방법 - XML Config

❑ 값(Value) 주입 설정 방법 2021.07.17 - [Back-End/Spring] - [Spring] 의존성 주입(DI) 설정 방법 - XML형식 Config 에서 의존 클래스(객체)를 주입하는 방법을 살펴보았다. 여기에 더해 Spring은 Bean Configuration을 이용해 Int, String과 같은 '값(Value)'를 주입하는 것도 지원하니 방법을 알아본다 1) Spring Bean 등록 ElectricMotor (Bean으로 등록될 Class) package com.test.di; public interface PowerUnit { void printMaxSpeedLimit(); } public class ElectricMotor implements PowerUnit { priv..

Back-End/Spring 2021.07.24

[Spring] 의존성 주입(DI)과 IoC 컨테이너의 개념

스프링 프레임워크의 기본이자 핵심 기능인 DI와 IoC Container를 배워보자 ❑ DI(Dependency Injection) 주입할 의존성 public interface PowerUnit { void useSource(); } public class GasolineEngine implements PowerUnit { @Override public void useSource() {} } public class ElectricMotor implements PowerUnit { @Override public void useSource() {} } 1. 의존 클래스 내부 정의 # 의존 클래스 내부 정의: 의존 Class ElectricMotor를 Car가 내부에서 직접 정의 public class Car..

Back-End/Spring 2021.07.16