尝试实例化此类时出现此错误:
public class ActivationAjaxBehavior extends AbstractAjaxBehavior {
private static final long serialVersionUID = 3103844752146887631L;
private final String tokenKey = "token";
@SpringBean
private RegistrationService registrationService;
public ActivationAjaxBehavior() {
super();
//Injector.get().inject(this);
}
@Override
public void onRequest() {
RequestCycle requestCycle = RequestCycle.get();
ServletWebRequest webRequest = (ServletWebRequest) requestCycle
.getRequest();
HttpServletRequest request = webRequest.getContainerRequest();
String extractedToken = (String) request.getParameter(tokenKey);
try {
registrationService.confirmUser(extractedToken);
proceedToSignInPage();
} catch (WrongTokenException e) {
e.printStackTrace();
proceedToSignUpPage();
}
}
private void proceedToSignInPage() {
throw new RestartResponseException(
SignInPage.class);
}
private void proceedToSignUpPage() {
throw new RestartResponseException(
RegisterPage.class);
}
}
我认为@SpringBean是这里的问题。但它可以在弹簧容器中使用......它可以在其他地方使用......
@Bean
public IRegistrationService userRegistrationService() {
return new RegistrationService(databaseBean());
}
该喷射器没有发生它得到
java.lang.RuntimeException: error while injecting object
Superclass has no null constructors but no arguments were given
答案 0 :(得分:4)
你的问题非常清楚。为了使用@SpringBean
注入依赖关系,您注入的类必须满足这些要求:
您的问题是第一条或第二条规则。因此,请检查这些条件并根据它们解决问题。