繁体   English   中英

我怎么能告诉玻璃鱼我春季依赖注射?

[英]how i can tell glassfish about my spring dependancy injection?

我是新来的,我正在使用休眠和弹簧依赖注入以及SOAP Web服务的项目。

我的问题是当我使用此类在控制台中运行项目时:

    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring-beans.xml");
    IServicesPharmacie pharmacieService = (IServicesPharmacie) context.getBean("service");
    context.close();
    Endpoint.publish("http://localhost:3597/Pharmacies", pharmacieService);
    System.out.println("The service has been published with success!");

我的项目工作正常,因为有以下3行:

    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring-beans.xml");
    IServicesPharmacie pharmacieService = (IServicesPharmacie) context.getBean("service");
    context.close();

我可以说说我的春季依赖注射。

但是我不知道如何在glassfish服务器上运行我的项目,并告诉他我的春季依赖注入,我想我大多数人都有一个web.xml!

我的spring-beans.xml是这样的:

<bean class="dao.PharmImpl" id="dao"></bean>

<bean class="metier.PharMetier" id="metier">
    <property name="phardao" ref="dao"></property>
</bean>

<bean class="services.ServicesPharmacie" id="service">
    <property name="servmetier" ref="metier" />
        </bean>
 </beans>

您需要配置一个ContextLoaderListener来引导应用程序中的spring。 如下所示:

<listener>
    <listener-class>
        org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>

也许如果您正在使用springMVC,则可以按以下步骤进行:

<servlet>
        <servlet-name>springServlet</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>springServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

请注意,URL模式取决于您的要求。

暂无
暂无

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

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