Mam problemy z moim kontrolerów Spring - Dostaję konstruktor domyślny nie znaleziono - ale mają konstruktora który próbuję stworzony przez applicationContext.xml - Herezje istotnych bitów:Spring MVC nie znaleziono konstruktora domyślnego?
<bean id="PcrfSimulator" class="com.rory.services.pcrf.simulator.PcrfSimulator" init-method="start">
</bean>
<bean id="CacheHandler" class="com.rory.services.pcrf.simulator.handlers.CacheHandler">
<constructor-arg index="0" type="com.rory.services.pcrf.simulator.CustomGxSessionIdCacheImpl">
<bean factory-bean="PcrfSimulator" factory-method="getGxSessionIdCache">
</bean>
</constructor-arg>
</bean>
Tzn. Najpierw tworzę komponent bean, a następnie próbuję przekazać wynik wywołania metody z tego komponentu bean do konstruktora komponentu drugiego komponentu bean (CacheHandler).
Here'e początek CacheHandler:
@Controller
public class CacheHandler {
private final CustomGxSessionIdCacheImpl gxSessionIdCache;
public CacheHandler(CustomGxSessionIdCacheImpl gxSessionIdCache) {
this.gxSessionIdCache = gxSessionIdCache;
}
Oto błąd Dostaję:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheHandler' defined in URL [jar:file:/users/rtorney/Documents/apache-tomcat-7.0.25/webapps/PCRFSimulator-4.0/WEB-INF/lib/PCRFSimulator-4.0.jar!/com/rory/services/pcrf/simulator/handlers/CacheHandler.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.rory.services.pcrf.simulator.handlers.CacheHandler]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.rory.services.pcrf.simulator.handlers.CacheHandler.<init>()
Każda pomoc jest mile widziane!
dzielimy ten sam pomysł ;-) –
wielki, dzięki za odpowiedzi wszystkich! – Rory
Świetnie to potwierdzić, potrzebuję albo konstruktora domyślnego, albo konstruktora przewodowego. – lwpro2