Question

I am using a scheduler with Spring technology using Quartz.

Is it possible to launch my context without creating a main class? Not using the following example:

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App 
{
    public static void main( String[] args ) throws Exception
    {
        new ClassPathXmlApplicationContext("Spring-Quartz.xml");
    }
}

For example I want my Context to be configured when I launch my jetty server.

Was it helpful?

Solution

If you launch your spring application on an application server, you can use a listener inside of the web.xml to start your spring container.

<listener>
   <listener-class>
        org.springframework.web.context.ContextLoaderListener
   </listener-class>
</listener> 
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:context.xml</param-value>
</context-param>

Another example: If you want to use spring in a blueprint OSGi environment, the blueprint extender starts all contexts in META-INF/spring or OSGI-INF/blueprint for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top