繁体   English   中英

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

[英]Starting application context without a main class

我正在使用Quartz的Spring技术调度程序。

是否可以在不创建主类的情况下启动我的上下文? 不使用以下示例:

import org.springframework.context.support.ClassPathXmlApplicationContext;

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

例如,我希望在启动jetty服务器时配置我的Context。

如果在应用程序服务器上启动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>

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

暂无
暂无

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

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