私は春のコントローラとの問題がある - 私にはデフォルトコンストラクタが見つからない取得しています - しかし、彼らは私がapplicationContext.xmlを介して作成しようとしていますコンストラクタ持っている - HERESに関連するビット:Spring MVCのデフォルトコンストラクタが見つかりませんでしたか?
<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>
をすなわち、
最初にBeanを作成し、そのBeanから2番目のBean(CacheHandler)コンストラクタにメソッド呼び出しの結果を渡そうとしています。
Here'e CacheHandlerの開始:
@Controller
public class CacheHandler {
private final CustomGxSessionIdCacheImpl gxSessionIdCache;
public CacheHandler(CustomGxSessionIdCacheImpl gxSessionIdCache) {
this.gxSessionIdCache = gxSessionIdCache;
}
ここで私が得ているエラーです:
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>()
すべてのヘルプははるかに高く評価されます!
我々は同じ考え;-)すべての答えを –
グレート、感謝を共有:
repository.xml
は、明示的な豆のインスタンス化を含め! – Rory
これを確認するには素晴らしいですが、springにはデフォルトコンストラクタか自動ワイヤコンストラクタが必要です。 – lwpro2