简体   繁体   English

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

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

I am new here, I am working on a project using hibernate and spring dependency injection and SOAP web service. 我是新来的,我正在使用休眠和弹簧依赖注入以及SOAP Web服务的项目。

My problem is when I run my project in the console using this class: 我的问题是当我使用此类在控制台中运行项目时:

    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!");

my project work fine, because with these 3 lines: 我的项目工作正常,因为有以下3行:

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

I can tell about my spring dependancy injection. 我可以说说我的春季依赖注射。

BUT i don't know how to run my project on a glassfish server, and tell him about my spring dependancy injection, I guess that I most have a web.xml!!!! 但是我不知道如何在glassfish服务器上运行我的项目,并告诉他我的春季依赖注入,我想我大多数人都有一个web.xml!

My spring-beans.xml is like that : 我的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>

You need to configure a ContextLoaderListener to bootstrap spring in your application. 您需要配置一个ContextLoaderListener来引导应用程序中的spring。 like below: 如下所示:

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

Perhaps if you are using springMVC its done as below: 也许如果您正在使用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>

Please note URL-pattern is based on your requirement. 请注意,URL模式取决于您的要求。

暂无
暂无

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

相关问题 Spring依赖注入:FileNotFound异常 - Spring Dependancy Injection: FileNotFound Exception 依赖注入期间的弹簧错误 - Spring error during dependancy injection 如何在Play Framework中防范交叉构建注入和其他依赖管理威胁? - How can I protect against cross-build injection and other dependancy management threats in Play Framework? 如何判断我的Spring启动应用程序是否处于调试模式? - How can I tell whether my Spring boot application is in debug mode? Glassfish仅使用4个内核中的2个进行异步处理,如何告诉它使用全部4个内核? 还是至少3个? - Glassfish Asynchronous only using 2 cores out of 4. How can I tell it to use all 4? Or at least 3? 如何在我的WAR中包含要部署到Glassfish的罐子? - How can I include jars in my WAR to be deployed to Glassfish? 如何设计我的 Spring 程序,以便当用户登录时,我可以判断他们是教职员工、学生还是教职员工? - How can I design my Spring program so that when a user logs in I can tell if they are a Staff member, student or faculty member? 如何在Spring Boot中将YAML属性与构造函数注入配合使用? - How can I use YAML properties with constructor injection in Spring Boot? 如何使用Spring进行参数化依赖注入? - How can I do parameterized dependency injection with Spring? 如何在 mapstruct 映射器中使用 spring 注入,存储库 class? - How can I use spring injection, A repository class in a mapstruct mapper?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM