简体   繁体   English

启动没有主类的应用程序上下文

[英]Starting application context without a main class

I am using a scheduler with Spring technology using Quartz. 我正在使用Quartz的Spring技术调度程序。

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. 例如,我希望在启动jetty服务器时配置我的Context。

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. 如果在应用程序服务器上启动spring应用程序,则可以使用web.xml内部的侦听器来启动spring容器。

<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. 另一个例子:如果你想在蓝图OSGi环境中使用spring,蓝图扩展器会为你启动META-INF / spring或OSGI-INF / blueprint中的所有上下文。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM