@Configuration,@Bean(name="helloBean") in springs example,this is remove configuration through xml into java class.
package javaconfig;
public interface HelloNaveen {
void print(String msg);
}
public interface HelloNaveen {
void print(String msg);
}
its implementation class
package javaconfig;
public class Hello implements HelloNaveen {
@Override
public void print(String msg) {
System.out.println("Hello"+msg);
}
}
package javaconfig;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Bean;
@Configuration
public class Appconfig {
@Bean(name="helloBean")
public HelloNaveen hello1()
{
return new Hello();
}
}
package javaconfig;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
public class Main {
public static void main(String[] args) {
ApplicationContext tx=new AnnotationConfigApplicationContext(Appconfig.class);
Hello h=(Hello)tx.getBean("helloBean");
h.print("Naveen && JYoti");
}
}