1. Java EE(Java Platform, Enterprise Edition)
: Java 를 이용한 서버개발 플랫폼
2. WAS(Web Application Server)
: Java EE 스펙에 따라 제품으로 구현한 것을 웹 애플리케이션 서버 또는 WAS라 한다.
[자바 기반이나 Java EE 비준수 웹 애플리케이션 서버]
1) 아파치 톰캣(Apache Tomcat) : 오픈 소스 재단 아파치 소프트웨어 재단의 오픈 소스 소프트웨어
2) 레진(Resin) : Caucho사의 제품
4) 제이런(JRun) : 매크로미디어사의 제품.
3. 컨테이너(Container)
: 애플리케이션과 그 의존성들(dependencies)을 독립된 단위로 묶어 격리, 어디서든 실행 가능하게 하는 것.
** JavaEE is a set of specifications implemented by different containers.
** Containers are JavaEE runtime environments that provide certain services to the components
they host such as life-cycle management, dependency injection, and so on.
These components use well-defined contracts to communicate with the JavaEE infrastructure and
with the other components.
** JavaEE is a superset of the JavaSE platform, which means JavaSE APIs can be used by any Java EE components.
4. Components
: JavaEE runtime 환경은 다음의 4가지 타입의 component를 정의하였고,
JavaEE runtime 구현시 반드시 이들 component 가 있어야 한다.
1) Applets are GUI applications that are executed in a web browser.
2) Applications are programs that are executed on a client.
They are typically GUIs or batch-processing programs that have access to all the facilities
of the Java EE middle tier.
3) Web applications(made of servlets, servlet filters, web event listeners, JSP pages, and JSF)
are executed in a web container and respond to HTTP requests from web clients.
Servlets also support SOAP and RESTtul web service endpoints.
4) Enterprise Java Beans are container-managed components for processing transactional business logic.
They can be accessed locally and remotely through RMI (or HTTP for SOAP and RESTful web services).
5. Monolithic architecture(2-tier architecture, 3-tier architecture)
: Presentation Logic, Business Logic, Data Access Logic이 단일 SW(혹은 모듈, 프로세스)로 구현된 것
** 2-tier architecture
: 여러 응용 프로그램들이 분산환경에서 데이터의 공유를 위하여 Data Access Logic 부분만 별도의 머신에 구현한 구조
(Presentation Logic + Business Logic) <-> (Data Access Logic <-> DataBase)
** 3-tier architecture
: 요즘 기업 웹 시스템의 대표적인 SW 구조
(Presentation Logic) <-> (Business Logic) <-> (Data Access Logic <-> DataBase)
6. Spring Framework
: 기존 J2EE(Java 2 Enterprise Edition) 기술이 가진, 고비용, 엔터프라이즈 급 어플리케이션의 기능들을
구현해놓은 프레임워크,
대한민국의 경우 스프링을 스프링을 공공기관의 웹 서비스 개발 시 사용을 권장하고 있는
전자정부 표준프레임워크의 기반 기술로서 수많은 기업, 금융 기관에서도 기본적인 프레임워크로 사용하고 있다.
7. 스프링 프레임워크 특징
1) 경량 컨테이너
: 자바 객체를 담고 있는 컨테이너
2) DI(Dependency Injection: 의존주입) 지원
: 설정파일로 객체 의존 관계 설정 및 생성
3) AOP(Aspect Orientec Programming) 지원
: 트랜잭션, 로깅, 보안 등 공통기능을 핵심기능에서 분리하여 적용 가능
4) IoC(Inversion Of Control) 제어반전 지원
5) POJO(Plain Old Java Object) 지원
: 컨테이너 안의 객체는 특별한 상속이 필요없는 평범한 자바 객체
6) 트랜잭션 처리를 위한 일관된 방법 지원 (영속성)
: 설정파일을 통한 일관된 트랜잭션 처리
7) 다양한 API 지원
: 엔터프라이즈 어플리케이션 개발에 필요한 다양한 API 지원
8. 프레임워크 (FrameWork)
: 어플리케이션 프레임워크 는 프로그래밍 개발환경에서 기본적인 구조를 제공하는 개발환경이다.
9. 프레임워크와 라이브러리 차이
[라이브러리] 사용하는 애플리케이션 코드는 애플리케이션 흐름을 직접 제어한다.
단지 동작하는 중에 필요한 기능이 있을 때 능동적으로 라이브러리를 사용할 뿐이다.
[프레임워크] 애플리케이션 코드가 프레임워크에 의해 사용된다.
애플리케이션 코드는 프레임워크가 짜놓은 틀에서 수동적으로 동작한다.
10. Maven
: 자바용 프로젝트 관리 도구,
아파치 라이선스로 배포되는 오픈 소스 소프트웨어,
Project object model(POM) 개념에 기반을 두고 있음
11. STS(Spring Tool Suite) 설치
: Spring Tool 4와 Spring Tool 3 Add On 필요
1) Spring Tool 4 설치
: Help > Eclipse Marketplace... 클릭
> spring 검색 > Spring Tools 4 (aka Spring Tool Suite 4) 4.6.2.RELEASE > Install 클릭
> Confirm 클릭
> I accept the terms of the license agreements 선택 후 Finish 클릭
> 설치중...!!
> Restart Now 클릭하면 설치 완
> 우클릭 > New > Other... 클릭 > Spring 검색했을때 아래의 사진과 같이 확인되면 정상적으로 STS 다운 된 것임
2) Spring Tool 3 Add On 필요 : 기존 Spring 프로젝트를 작업하려면 STS3 Add-on도 설치해야 한다.
: Help > Eclipse Marketplace... 클릭
> spring 검색 > Spring Tools 3 Add-On for Spring Tools 4 3.9.13.CI > Install 클릭
> Confirm 클릭
> I accept the terms of the license agreements 선택 후 Finish 클릭
> 설치중...!!
> Restart Now 클릭하면 설치 완
> 재시작 후 welcome page가 Spring으로 바뀜
> 아래의 그림과 같이 아이콘이 생김
> Spring 관점 추가 가능하고 Spring 프로젝트도 생성 가능함
12. 라이브러리들은 사용자 폴더 내 .m2 라는 폴더에 저장
13. java 버전과 spring-framework 버전을 pom.xml(Maven 빌드 설정 파일, 메이븐 파일, 빌드파일)에서 변경 가능
[실습코드]
1. STS01_HelloSpring
** src/main/java > com.lec.spring > HelloMain.java
package com.lec.spring;
public class HelloMain {
public static void main(String[] args) {
System.out.println("Hello spring");
}
}
2. STS02_DI1_bean
1) DIMain01, DIMain02
** [src/main/java] com.lec.spring > MessageBean 인터페이스
package com.lec.spring;
public interface MessageBean {
public abstract void sayHello();
}
** [src/main/java] com.lec.spring > MessageKor.java
package com.lec.spring;
public class MessageKor implements MessageBean {
String msgKor = "안녕하세요";
// 생성자 : 언제 생성되는지 예의 주시
public MessageKor() {
System.out.println("MessageKor() 생성");
}
@Override
public void sayHello() {
System.out.println(msgKor);
}
}
** [src/main/java] com.lec.spring > MessageEng.java
package com.lec.spring;
public class MessageEng implements MessageBean {
String msgEng = "Good Morning";
public MessageEng() {
System.out.println("MessageEng() 생성");
}
@Override
public void sayHello() {
System.out.println(msgEng);
}
}
** [src/main/resources] appCtx.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- bean 객체 정의 -->
<bean id="messageBean" class="com.lec.spring.MessageEng" />
<!--
com.lec.spring.MessageKor messageBean = new com.lec.spring.MessageKor();
-->
</beans>
** [src/main/java] com.lec.spring.di01 > DIMain01.java
package com.lec.spring.di01;
import com.lec.spring.*;
/*
* Dependency Injection (DI, 의존 주입)
*
* 필요한 객체를 '누가' 만들어 사용하나?
*
* 방법1 : 직접 생성(new)하여 사용
*
*/
public class DIMain01 {
public static void main(String[] args) {
System.out.println("Main 시작");
MessageBean msg = null;
// 필요한 MessageBean 객체를
// msg = new MessageKor(); // 직접 만들어(new) 사용
// msg.sayHello();
// 의존하고 있던 객체의 버전 등이 업그레이드 되면(설계 변경이 되면)
// 의존하고 있던 객체를 재컴파일 해야 한다.(수정해야한다!)
msg = new MessageEng();
msg.sayHello();
System.out.println("Main 종료");
}
}
** [src/main/java] com.lec.spring.di01 > DIMain02.java
package com.lec.spring.di02;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
import com.lec.spring.MessageBean;
/*
* Dependency Injection (DI, 의존주입)
* 필요한 객체는 누가 만들어 사용하나?
*
* 방법2 : 외부에서 만들어 주입 (injection)
* 스프링 특징 의존 주입 (Dependenty Injection) 사용
*
* 즉 '외부' 에서 만들어 놓은 것을 가져 온다
*
*/
public class DIMain02 {
public static void main(String[] args) {
System.out.println("Main 시작");
// 스프링 설정 파일 resource 명시
String configLocation = "classpath:appCtx.xml";
// ApplicationContext 객체를 만드는 시점에서 bean 객체가 생성된다!
AbstractApplicationContext ctx =
new GenericXmlApplicationContext(configLocation);
System.out.println("Application Context 컨테이너 생성 완료\n");
// 외부에서 만들어진 객체 주입(injection)
MessageBean msg =
ctx.getBean("messageBean", MessageBean.class);
// ↑ bean의 id 값, ↑ bean 의 타입. 다형성 적용!
msg.sayHello();
ctx.close(); // Application Context 컨테이너는 반드시 close()!
System.out.println("Main 종료");
// Ctrl + T : 족보 확인 가능
ApplicationContext ctx2;
} // end Main()
}
2) DIMain03, DIMain04
** [src/main/java] com.lec.spring > Score.java
package com.lec.spring;
import java.util.Arrays;
import java.util.List;
public class Score {
int kor; // 국어 점수
int eng; // 영어 점수
int math; // 수학 점수
String comment; // 평가 코멘트
// 기본 생성자
public Score() {
System.out.println("Score() 생성");
}
// 매개변수 생성자
public Score(int kor, int eng, int math, String comment) {
super();
System.out.printf("Score(%d, %d, %d, %s) 생성\n", kor, eng, math, comment);
this.kor = kor;
this.eng = eng;
this.math = math;
this.comment = comment;
}
// 매개변수 생성자, 순서 변경
public Score(int kor, int eng, String comment, int math) {
super();
System.out.printf("Score(%d, %d, %s, %d) 생성\n", kor, eng, comment, math);
this.kor = kor;
this.eng = eng;
this.math = math;
this.comment = comment;
}
// 매개변수 생성자
public Score(int[] arr) {
System.out.printf("Score(%s) 생성\n", Arrays.toString(arr));
this.kor = arr[0];
this.eng = arr[1];
this.math = arr[2];
}
// getter, setter
public int getKor() {
return kor;
}
public void setKor(int kor) {
this.kor = kor;
}
public int getEng() {
return eng;
}
public void setEng(int eng) {
this.eng = eng;
}
public int getMath() {
return math;
}
public void setMath(int math) {
this.math = math;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public void setScore(List<Integer> scores) {
this.kor = scores.get(0);
this.eng = scores.get(1);
this.math = scores.get(2);
}
// 출력할때 이쁘게 나올려고..!!
@Override
public String toString() {
return String.format("[Score 국어:%d 영어:%d 수학:%d 평가:%s]",
kor, eng, math, comment);
}
}
** [src/main/java] com.lec.spring > Student.java
package com.lec.spring;
public class Student {
String name;
int age;
Score score; // reference 타입
// 기본생성자
public Student() {
System.out.println("Student() 생성자");
}
// 매개변수 생성자
public Student(String name, int age, Score score) {
super();
System.out.printf("Student(%s, %d, %s) 생성\n",
name, age, score.toString());
this.name = name;
this.age = age;
this.score = score;
}
// getter, setter
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public Score getScore() {
return score;
}
public void setScore(Score score) { // 매개변수가 reference 타입!
this.score = score;
}
@Override
public String toString() {
return String.format("[Student 이름:%s, 나이:%d, 성적:%s]",
name, age, score.toString());
}
}
** [src/main/resources] scoreCtx.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- 기본 생성자 -->
<bean id="myScore1" class="com.lec.spring.Score"/>
<!-- 매개변수 지정, constructor-arg -->
<bean id="myScore2" class="com.lec.spring.Score">
<!-- 생성자 매개변수 4개이고 아래 순서대로 생성자에 입력됨 -->
<constructor-arg value="88"/>
<constructor-arg value="70"/>
<!-- <constructor-arg value="91"/> -->
<constructor-arg>
<value>91</value> <!-- value 태그로 값 명시 가능 -->
</constructor-arg>
<constructor-arg value="좋아요"/>
<!-- 생성자의 순서대로 값을 설정해야함,
생성자의 순서대로 선언되지 않으면 BeanCreationException 발생 -->
</bean>
<!-- 매개 변수 지정, index 사용 -->
<bean id="myScore3" class="com.lec.spring.Score">
<constructor-arg index="2" value="91"/>
<constructor-arg index="1" value="70"/>
<constructor-arg index="0" value="88"/>
<constructor-arg index="3">
<value>그저 그래요</value>
</constructor-arg>
</bean>
<!-- 매개변수 type 사용 -->
<bean id="myScore4" class="com.lec.spring.Score">
<!-- 원래는 생성자의 순서대로 값을 설정해야 하나, 모호성 없이 type이 명시되면 동작 가능함 -->
<constructor-arg type="int" value="88"/>
<constructor-arg type="int" value="70"/>
<constructor-arg type="java.lang.String" value="나빠요"/>
<constructor-arg type="int" value="91"/>
<!-- 불가능 : 자동 형변화 적용 안됨 -->
<!--
<constructor-arg type="int" value="88"/>
<constructor-arg type="byte" value="70"/>
<constructor-arg type="java.lang.String" value="나빠요"/>
<constructor-arg type="short" value="91"/>
-->
</bean>
<!-- 배열/List 타입 매개변수 생성자 -->
<bean id="myScore5" class="com.lec.spring.Score">
<constructor-arg>
<list>
<value>88</value>
<value>70</value>
<value>91</value>
</list>
</constructor-arg>
</bean>
<!-- setter 메소드 사용 -->
<bean id="myScore6" class="com.lec.spring.Score">
<!-- 일단은 기본생성자로 생성! -->
<property name="kor" value="88"/>
<!-- myScore6.setkor(88) -->
<property name="eng" value="70"/>
<!-- <property name="math" value="91"/> -->
<property name="math">
<value>91</value>
</property>
<property name="comment" value="끝내줌!"/>
</bean>
<!-- 생성자와 setter 동시에 가능
생성자 먼저 호출되고, setter 수행됨 -->
<bean id="myScore7" class="com.lec.spring.Score">
<constructor-arg value="88"/>
<property name="comment" value="꿈만같다"/>
<constructor-arg value="70"/>
<constructor-arg value="91"/>
<constructor-arg value="악몽이다"/>
<!-- 순서상 악몽이다가 출력될 것 같지만 꿈만 같다가 출력된다
왜? constructor 후에 property가 실행되기 때문..!! -->
</bean>
<bean id="myScore8" class="com.lec.spring.Score">
<property name="score"> <!-- setter의 name을 name에 작성하면 됨 -->
<list>
<value>100</value>
<value>200</value>
<value>300</value>
</list>
</property>
</bean>
</beans>
** [src/main/resources] studentCtx.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- [ex] 팩토리, 객체가 만들어지는 공장, 순차적으로 객체 생성됨 -->
<bean id="scoreA" class="com.lec.spring.Score">
<constructor-arg value="88"/>
<constructor-arg value="70"/>
<constructor-arg value="91"/>
<constructor-arg value="좋아요"/>
</bean>
<!-- 생성자 매개변수 reference 타입은 ref 사용 -->
<bean id="Hong" class="com.lec.spring.Student">
<constructor-arg value="홍성용"/>
<constructor-arg value="28"/>
<constructor-arg ref="scoreA"/>
</bean>
<!-- setter 와 ref 사용 -->
<bean id="Joo" class="com.lec.spring.Student">
<property name="name" value="윤주현주인주"/>
<property name="age" value="23"/>
<property name="score" ref="scoreA"/>
</bean>
</beans>
** [src/main/java] com.lec.spring.di03 > DIMain03.java
package com.lec.spring.di03;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
import com.lec.spring.Score;
public class DIMain03 {
public static void main(String[] args) {
System.out.println("Main 시작");
// ApplicationContext (컨테이너) 생성, (빈(bean)도 자동 생성)
AbstractApplicationContext ctx =
new GenericXmlApplicationContext("classpath:scoreCtx.xml");
System.out.println("컨테이너 생성\n");
Score score = null;
score = ctx.getBean("myScore1", Score.class);
System.out.println(score);
// getBean(id)는 Object 리턴. 형변환해서 사용 가능.
score = (Score)ctx.getBean("myScore2");
System.out.println(score);
score = ctx.getBean("myScore3", Score.class);
System.out.println(score);
score = ctx.getBean("myScore4", Score.class);
System.out.println(score);
score = ctx.getBean("myScore5", Score.class);
System.out.println(score);
score = ctx.getBean("myScore6", Score.class);
System.out.println(score);
score = ctx.getBean("myScore7", Score.class);
System.out.println(score);
System.out.println();
System.out.println("생성된 빈의 개수" + ctx.getBeanDefinitionCount());
for(int i = 1; i <= ctx.getBeanDefinitionCount(); i++) {
System.out.println(ctx.getBean("myScore" + i));
// ctx.getBean("myScore" + i) : 오브젝트를 리턴함...!!
// 오브잭트를 System.out 하면 toString으로 출력됨..!!
}
System.out.println();
score = ctx.getBean("myScore8", Score.class);
System.out.println(score);
ctx.close(); // 컨테이너 종료
System.out.println("Main 종료");
}
}
** [src/main/java] com.lec.spring.di04 > DIMain04.java
package com.lec.spring.di04;
import org.springframework.context.support.GenericXmlApplicationContext;
import com.lec.spring.Student;
public class DIMain04 {
public static void main(String[] args) {
System.out.println("Main 시작");
// 컨테이너 생성
GenericXmlApplicationContext ctx
= new GenericXmlApplicationContext("classpath:studentCtx.xml");
System.out.println("--컨테이너 생성--");
Student stu1 = ctx.getBean("Hong", Student.class);
System.out.println(stu1);
Student stu2 = ctx.getBean("Joo", Student.class);
System.out.println(stu2);
System.out.println();
stu2.getScore().setKor(100);
System.out.println(stu2);
System.out.println(stu1); // Hong의 국어 점수도 바뀌어 있다
// 왜냐하면 Hong과 Joo는 같은 score의 레퍼런싱 하고 있어서 그럼...!!
ctx.close();
System.out.println("Main 종료");
}
}
4) DIMain05
** [src/main/resources] studentCtx2.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="score1" class="com.lec.spring.Score"
c:kor="88" c:eng="70" c:math="91" c:comment="그럭저럭"/>
<!-- 해당 생성자가 없으면 에러 : Could not resolve matching constructor
<bean id="score2" class="com.lec.spring.Score"
c:kor="88"/>
-->
<!-- p : setter 호출,
위의 코드는 에러이나 아래의 코드는 에러가 아님 -->
<bean id="score2" class="com.lec.spring.Score"
p:kor="88"/> <!-- 기본 생성자를 만든 다음에 setkor()를 호출 -->
<!-- c : 생성자 매개변수가 ref 인 경우 -->
<bean id="stu1" class="com.lec.spring.Student"
c:name="준영진영수영" c:age="25"
c:score-ref="score1"/>
<!-- p : setter 매개변수가 ref 인 경우 -->
<bean id="stu2" class="com.lec.spring.Student"
p:name="수빈상빈" p:age="100"
p:score-ref="score2"/>
</beans>
** [src/main/java] com.lec.spring.di05 > DIMain05
package com.lec.spring.di05;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
import com.lec.spring.Score;
public class DIMain05 {
public static void main(String[] args) {
System.out.println("Main 시작");
// AbstractApplicationContext는 GenericXmlApplicationContext의 조상
AbstractApplicationContext ctx
= new GenericXmlApplicationContext("classpath:studentCtx2.xml");
System.out.println("--컨테이너 생성--");
Score score = null;
score = (Score)ctx.getBean("score1");
System.out.println(score);
System.out.println(ctx.getBean("score2"));
System.out.println(ctx.getBean("stu1"));
System.out.println(ctx.getBean("stu2"));
ctx.close();
System.out.println("Main 종료");
}
}
3. 빈 객체 생성 연습
** [src/main/java] ex2_1 > OperatorBean 인터페이스
package ex2_1;
public interface OperatorBean {
public abstract int doOperate();
}
** [src/main/java] ex2_1 > PlusOp.java
package ex2_1;
public class PlusOp implements OperatorBean {
int operand1;
int operand2;
public PlusOp() {}
public PlusOp(int operand1, int operand2) {
super();
this.operand1 = operand1;
this.operand2 = operand2;
}
public final int getOperand1() {
return operand1;
}
public final void setOperand1(int operand1) {
this.operand1 = operand1;
}
public final int getOperand2() {
return operand2;
}
public final void setOperand2(int operand2) {
this.operand2 = operand2;
}
@Override
public int doOperate() {
return operand1 + operand2;
}
}
** [src/main/java] ex2_1 > MinusOp.java
package ex2_1;
public class MinusOp implements OperatorBean {
int operand1;
int operand2;
public MinusOp() {}
public MinusOp(int operand1, int operand2) {
super();
this.operand1 = operand1;
this.operand2 = operand2;
}
public final int getOperand1() {
return operand1;
}
public final void setOperand1(int operand1) {
this.operand1 = operand1;
}
public final int getOperand2() {
return operand2;
}
public final void setOperand2(int operand2) {
this.operand2 = operand2;
}
@Override
public int doOperate() {
return operand1 - operand2;
}
}
** [src/main/resources] applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="op1" class="ex2_1.PlusOp">
<constructor-arg value="10"/>
<constructor-arg value="7"/>
</bean>
<bean id="op2" class="ex2_1.MinusOp">
<constructor-arg value="20"/>
<constructor-arg value="32"/>
</bean>
</beans>
** [src/main/java] ex2_1 > DIApp.java
package ex2_1;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
public class DIApp {
public static void main(String[] args) {
System.out.println("Main 시작");
AbstractApplicationContext ctx
= new GenericXmlApplicationContext("classpath:applicationContext.xml");
OperatorBean operator = null;
operator = ctx.getBean("op1", OperatorBean.class);
int value = operator.doOperate();
System.out.println("결과:" + value);
System.out.println();
operator = ctx.getBean("op2", OperatorBean.class);
value = operator.doOperate();
System.out.println("결과:" + value);
ctx.close();
System.out.println("Main 종료");
}
}
'웹_프론트_백엔드 > JAVA프레임윅기반_풀스택' 카테고리의 다른 글
2020.06.22 (0) | 2020.06.22 |
---|---|
2020.06.19 (0) | 2020.06.19 |
2020.06.17 (0) | 2020.06.17 |
2020.06.16 (0) | 2020.06.16 |
JSP Team Project(2020.05.25 ~ 2020.06.15) (0) | 2020.06.16 |