In this tutorial I will show you how you can access your Spring-ApplicationContext from everywhere in your Application.




Maven configuration


First is our dependency management, we need to add spring-core and spring-context to our classpath.




Simple service


We have a simple service that's going to be managed by springs container. It has a simple Greeting message.


package org.camelcode;

public class GreetingMessage {

    public void sayHello(){
        System.out.println("Hello, World!");
    }
}