package di.hello;
public class EnHello implements Hello{
public String sayHello(String name){
return name+"! How are you?";
}
}
package di.hello;
public interface Hello {
public String sayHello(String name);
}
package di.hello;
public class KorHello implements Hello{
public String sayHello(String name){
return "안녕하세요"+name+"님!";
}
}
package di.main;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import di.hello.KorHello;
public class TestHello {
//Spring Container객체 조회 - 설정파일의 위치를 문자열로 알려준다.
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("di/hello/config/hello.xml");
Object obj = ctx.getBean("hello");
KorHello hello = (KorHello)obj;
String greeting = hello.sayHello("이순신");
System.out.println(greeting);
}
}
package di.main;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import di.hello.EnHello;
import di.hello.Hello;
import di.hello.KorHello;
public class TestHello {
//Spring Container객체 조회 - 설정파일의 위치를 문자열로 알려준다.
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("di/hello/config/hello.xml");
Object obj = ctx.getBean("hello");
Hello hello = (Hello)obj;
String greeting = hello.sayHello("이순신");
System.out.println(greeting);
}
}