我越来越:无法实例化[..]:找不到默认构造函数;
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mz.server.rest.braintree.webhooks.SubscriptionWebhook]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.mz.server.rest.braintree.webhooks.SubscriptionWebhook.<init>()
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:85)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1098)
... 22 more
即使我已经定义了这个构造在我applicatioContext-restapi.xml
文件:
<bean id="subscriptionWebhook" class="com.mz.server.rest.braintree.webhooks.SubscriptionWebhook">
<constructor-arg ref="dslContext" />
</bean>
任何想法,为什么?
@RestController
public class SubscriptionWebhook {
private final static Logger LOGGER = Logger.getLogger(SubscriptionWebhook.class.getName());
private AdminService adminService;
public SubscriptionWebhook(DSLContext ctx) {
this.adminService = new AdminService(ctx);
}
}
错误是'com.mz.server.rest.UserVerificationResource',而不是'com.mz.server.rest.braintree.webhooks.SubscriptionWebhook' – mszymborski
@mszymborski感谢提示和抱歉的困惑。这是一个复制和粘贴错误。我有一个以上的对象,我尝试这样使用。我纠正了我的帖子.. – displayname
你有没有试过简单地在控制器中使用注释注入它? @Inject/@ Autowired – mszymborski