설정을 테스트하기 위해 다음 예제에 제시된 대로 새로운 Main 메서드를 만들어 보자. 이 예제에서는 스프링 컨텍스트를 시작하고, 컨텍스트에서 CommentService 타입의 빈을 가져온 후 publishComment(Comment comment) 메서드를 호출한다.
예제 4-12 Main 클래스
public class Main {
public static void main(String[] args) {
var context =
new AnnotationConfigApplicationContext(ProjectConfiguration.class);
var comment = new Comment();
comment.setAuthor("Laurentiu");
comment.setText("Demo comment");
var commentService = context.getBean(CommentService.class);
commentService.publishComment(comment);
}
}