找不到构造函数 'java.lang.String' 的参数 0
Parameter 0 of constructor 'java.lang.String' that could not be found
我的项目是用Grails 4开发的,实际上我正在从Grails 2升级到Grails 4。你能给我一个解决方案吗?我该如何解决?谢谢
错误:
Parameter 0 of constructor in com.bv.session.AjaxAwareAuthenticationEntryPoint required a bean of type
'java.lang.String' that could not be found.
recourse.groovy:
beans = {
authenticationEntryPoint(com.bv.session.AjaxAwareAuthenticationEntryPoint) {
loginFormUrl = '/login/auth'
grailsUrlMappingsHolder = ref('grailsUrlMappingsHolder')
portMapper = ref('portMapper')
portResolver = ref('portResolver')
}
}
Class:
public class AjaxAwareAuthenticationEntryPoint extends LoginUrlAuthenticationEntryPoint {
private UrlMappingsHolder proxyBean;
public AjaxAwareAuthenticationEntryPoint(String loginFormUrl) {
super(loginFormUrl);
}
@Override
protected String determineUrlToUseForThisRequest(final HttpServletRequest request,
final HttpServletResponse response, final AuthenticationException e){
String controllerName = (String)proxyBean.match(request.getServletPath()).getParameters().get("controller");
String ajaxHeader = ((HttpServletRequest) request).getHeader("X-Requested-With");
if ("XMLHttpRequest".equals(ajaxHeader)){
return "/login/auth?session_expired_ajax=true";
}
if(request.getSession(false).isNew() || "index.gsp".equals(controllerName)) {
return "/login/auth";
}else{
return "/login/auth?session_expired=true";
}
}
public void setGrailsUrlMappingsHolder(UrlMappingsHolder proxyBean) {
this.proxyBean = proxyBean;
}
}
工具:
- Grails 4
- Spring-安全4
来自的
文档:
19.3 The BeanBuilder DSL Explained
Using Constructor Arguments
Constructor arguments can be defined using parameters to each
bean-defining method. Put them after the first argument (the Class):
bb.beans {
exampleBean(MyExampleBean, "firstArgument", 2) {
someProperty = [1, 2, 3]
}
}
This configuration corresponds to a MyExampleBean
with a constructor that looks like this:
MyExampleBean(String foo, int bar) {
...
}
我的项目是用Grails 4开发的,实际上我正在从Grails 2升级到Grails 4。你能给我一个解决方案吗?我该如何解决?谢谢
错误:
Parameter 0 of constructor in com.bv.session.AjaxAwareAuthenticationEntryPoint required a bean of type
'java.lang.String' that could not be found.
recourse.groovy:
beans = {
authenticationEntryPoint(com.bv.session.AjaxAwareAuthenticationEntryPoint) {
loginFormUrl = '/login/auth'
grailsUrlMappingsHolder = ref('grailsUrlMappingsHolder')
portMapper = ref('portMapper')
portResolver = ref('portResolver')
}
}
Class:
public class AjaxAwareAuthenticationEntryPoint extends LoginUrlAuthenticationEntryPoint {
private UrlMappingsHolder proxyBean;
public AjaxAwareAuthenticationEntryPoint(String loginFormUrl) {
super(loginFormUrl);
}
@Override
protected String determineUrlToUseForThisRequest(final HttpServletRequest request,
final HttpServletResponse response, final AuthenticationException e){
String controllerName = (String)proxyBean.match(request.getServletPath()).getParameters().get("controller");
String ajaxHeader = ((HttpServletRequest) request).getHeader("X-Requested-With");
if ("XMLHttpRequest".equals(ajaxHeader)){
return "/login/auth?session_expired_ajax=true";
}
if(request.getSession(false).isNew() || "index.gsp".equals(controllerName)) {
return "/login/auth";
}else{
return "/login/auth?session_expired=true";
}
}
public void setGrailsUrlMappingsHolder(UrlMappingsHolder proxyBean) {
this.proxyBean = proxyBean;
}
}
工具:
- Grails 4
- Spring-安全4
来自的 文档:
19.3 The BeanBuilder DSL Explained
Using Constructor Arguments
Constructor arguments can be defined using parameters to each bean-defining method. Put them after the first argument (the Class):
bb.beans { exampleBean(MyExampleBean, "firstArgument", 2) { someProperty = [1, 2, 3] } }
This configuration corresponds to a
MyExampleBean
with a constructor that looks like this:MyExampleBean(String foo, int bar) { ... }