Hi everyone

Probably a simple question, so here we go: when writing unit tests, I can use @ContextConfiguration to set my spring context and have the load time weaver autowire my @Configurable classes' fields.

However, running the main program like this:

Code:
@ContextConfiguration(locations = {"classpath:/com/emc/config/spring.cfg.xml"})
@Configurable
public class Hello {
	@Autowired
	private HelloService service;
	
	public void sayHello() {
		service.sayHello("Tom");
	}
	
	public static void main(String[] args) {
		Hello hello = new Hello();
		hello.sayHello();
	}
}
does not seem to work. Instead, I'm continually being advised to start my program like this:

Code:
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:/com/emc/config/spring.cfg.xml");
System.out.println(((HelloService)ctx.getBean("HelloService")).sayHello("Tom"));
Personally, however, I find the other way using @ContextConfiguration much more elegant. How can such an annotation based context load be achieved in this situation?

Thank you in advance for any reply.

Best regards
Kessi