본문 바로가기
Spring

@Component 사용법 ( 2 )

by Coarti 2023. 8. 7.

[ 이전 글 ] @Component 사용법 ( 1 )

 

@Component 사용법 ( 1 )

@Autowired, @Qualifier 사용법 @Autowired, @Qualifier 사용법 [ 이전 글 ] XML 사용법 XML 사용법 [ 이전 글 ] Inversion of Control Container ( Ioc Container ) Inversion of Control Container ( Ioc Container ) ( 이전 글과 이어지는 내

cloakinghost.tistory.com

XML 파일에 남은 내용은 한 줄 뿐이다

<context:component-scan base-package="spring.di.ui, spring.di.entity"/>

객체 생성 시 초기값을 지정해보자

package spring.di.entity;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class ScoreExam implements Exam {

	@Value("20")
	private int kor;
	@Value("30")
	private int eng;
	private int math;
	private int com;
    
// 이하 생략

}
728x90

'Spring' 카테고리의 다른 글

Java Configuration  (0) 2023.08.07
@Component 분석 ( 3 )  (0) 2023.08.07
@Component 사용법 ( 1 )  (0) 2023.08.05
@Autowired, @Qualifier 사용법  (0) 2023.08.05
XML 사용법  (0) 2023.08.05