Spring Spring 4 gradle top2blue 2015. 12. 16. 09:56 package demo; public interface MessageService { public String getMessage(); public String getMessage(String name); } package demo; public class HelloWorldMessage implements MessageService { public String getMessage() { return "Hello World"; } @Override public String getMessage(String name) { return "Hi! " + name; } } package demo; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; public class Application { @Bean MessageService helloWorldMessageService() { return new HelloWorldMessage(); } public static void main(String[] args) { ApplicationContext context = new AnnotationConfigApplicationContext(Application.class); MessageService service = context.getBean(MessageService.class); System.out.println(service.getMessage()); System.out.println(service.getMessage("한사람")); } } build.gradle apply plugin: 'application' mainClassName = 'demo.Application' repositories { mavenCentral() } dependencies { compile 'org.springframework:spring-context:4.1.2.RELEASE' testCompile 'junit:junit:4.11' }