开发者

Disable Spring Dependency Injection in Glassfish

开发者 https://www.devze.com 2023-02-22 04:30 出处:网络
How can I disable Dependency Injection in Glassfish so that it doesn\'t co开发者_如何学JAVAnflict with spring?

How can I disable Dependency Injection in Glassfish so that it doesn't co开发者_如何学JAVAnflict with spring?

Is it possible to configure in glassfish-web.xml


Spring can use different annotations that GF wont' understand. Without some examples of your code it's hard to go further.

There isn't anything that's going to turn DI off... it's part of the container, so you'll need to use annotations it doesn't care about.


I finally found a solution. It is possible to inject an EntityManager in Spring without resorting to @PersistenceContext. There is a Spring factorybean to create a shared EntityManager. Given an Entity Manager Factory:

<bean id="entityManager" class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="myJpaFacade" class="com.example.MyJpaFacade">
    <property name="entityManager" ref="entityManager" />
</bean>

Now I can remove the @PersistenceContext annotation from MyJpaFacade so that Glassfish doesn't try to lookup and inject an entity manager into the entityManager property.

0

精彩评论

暂无评论...
验证码 换一张
取 消