🍃 Spring, Spring Boot/스프링 프레임워크 기초

    [Java / Spring] 2. DI 값 설정

    이전 시간에 작성한 코드의 결과는 잘 출력되기는 하나 실질적인 값이 들어가 있지 않아 의미없는 결과를 출력하였다. 따라서 클래스에 getter와 setter를 추가한 뒤, setting.xml 파일을 다음과 같이 수정해주었다. 태그를 사용해 NewlecExam 클래스 안에 있는 getter, setter 함수를 이용한 것이다. 위와 다른 방법으로 생성자를 이용하는 방법이 있다. 우선 NewlecExam 클래스의 생성자는 다음과 같다. public NewlecExam(int kor, int eng, int math, int com) { this.kor = kor; this.eng = eng; this.math = math; this.com = com; } 위의 생성자를 이용해서 DI 값을 지정하기 위해서는..

    [JAVA / Spring] 1. 스프링을 통해 DI 설정

    Program.java package spring.di; import spring.di.entity.Exam; import spring.di.entity.NewlecExam; import spring.di.ui.ExamConsole; import spring.di.ui.GridExamConsole; import spring.di.ui.InlineExamConsole; public class Program { public static void main(String[] args) { Exam exam = new NewlecExam(); //ExamConsole console = new InlineExamConsole(exam); // DI ExamConsole console = new GridExamCons..