Ich habe ein Webmodul mit JSF 2 Ende Frühling 4.3. In einer Backing-Bean verwende ich @Autowired
für DI eines Dienstes einer JAR. Im EAR-Modul gibt es WAR, JAR mit @Service
Spring und JAR mit Spring-Konfigurationsdatei.Spring @Autowired (erforderlich = wahr) ist null
Unterhalb eines web.xml
Schnipsel:
<context-param>
<param-name>locatorFactorySelector</param-name>
<param-value>classpath:beanRefContext.xml</param-value>
</context-param>
<context-param>
<param-name>parentContextKey</param-name>
<param-value>sharedContext</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
applicationContext.xml
:
<context:annotation-config />
<context:spring-configured />
<!-- package of @Service class in jar module in EAR-- >
<context:component-scan base-package="com.ipdb.service" />
beanRefContext.xml:
<bean id="sharedContext" class="org.springframework.context.support.ClassPathXmlApplicationContext"> <constructor-arg> <list> <value>spring-ctx.xml</value> </list> </constructor-arg> </bean>
Als ich @Autowired(required=null)
in einem Hintergrund-Bean verwenden ist der Wert null
(es ist keine Ausnahme). Meine JSF-Bean
@Component
@ManagedBean
@ViewScoped
public class PortfolioController {
@Autowired(required = true)
private PortfolioService portfolioService;
...
Können Sie mir bitte helfen.
Es ist nicht ein Spring-Bean und Frühling ist nicht die Verwaltung oder autowiring es somit entfernen. – chrylis
Da Ihre Frage ursprünglich mit [spring-mvc] getaggt wurde, hier ein paar Denkanstöße: http://stackoverflow.com/q/18744910 – BalusC