- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我尝试在运行时启动 Hybris 平台时,出现此错误:
WARN [localhost-startStop-1] [TenantIgnoreXmlWebApplicationContext] Exception encountered during context initialization - cancelling refresh at
tempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'checkoutController': Injection of resource depend
encies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'autoLoginStrategy' de
fined in ServletContext resource [/WEB-INF/config/common-spring-security-config.xml]: Cannot resolve reference to bean 'rememberMeServices' whil
e setting bean property 'rememberMeServices'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean w
ith name 'defaultRememberMeServices' defined in ServletContext resource [/WEB-INF/config/common-spring-security-config.xml]: Instantiation of be
an failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.sap.hybris.fs.storefront.securit
y.AcceleratorRememberMeServices]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.sap.hybris.fs.storefron
t.security.AcceleratorRememberMeServices.<init>()
AcceleratorRememberMeServices 类是这样的:
/*
* [y] hybris Platform
*
* Copyright (c) 2000-2015 hybris AG
* All rights reserved.
*
* This software is the confidential and proprietary information of hybris
* ("Confidential Information"). You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the
* license agreement you entered into with hybris.
*
*
*/
package com.sap.hybris.fs.storefront.security;
import de.hybris.platform.acceleratorservices.urlencoder.UrlEncoderService;
import de.hybris.platform.acceleratorstorefrontcommons.constants.WebConstants;
import de.hybris.platform.commercefacades.customer.CustomerFacade;
import de.hybris.platform.commercefacades.storesession.StoreSessionFacade;
import de.hybris.platform.commerceservices.security.SecureTokenService;
import de.hybris.platform.commerceservices.strategies.CheckoutCustomerStrategy;
import de.hybris.platform.servicelayer.i18n.CommonI18NService;
import de.hybris.platform.servicelayer.user.UserService;
import com.sap.hybris.fs.storefront.web.wrappers.RemoveEncodingHttpServletRequestWrapper;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.security.authentication.RememberMeAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices;
public class AcceleratorRememberMeServices extends TokenBasedRememberMeServices
{
public AcceleratorRememberMeServices(String key, UserDetailsService userDetailsService) {
super(key, userDetailsService);
// YTODO Auto-generated constructor stub
}
private UserService userService;
private CustomerFacade customerFacade;
private CheckoutCustomerStrategy checkoutCustomerStrategy;
private StoreSessionFacade storeSessionFacade;
private CommonI18NService commonI18NService;
private UrlEncoderService urlEncoderService;
private SecureTokenService secureTokenService;
@Override
protected void setCookie(final String[] tokens, final int maxAge, final HttpServletRequest request,
final HttpServletResponse response)
{
if (!getCheckoutCustomerStrategy().isAnonymousCheckout())
{
super.setCookie(tokens, maxAge, new RemoveEncodingHttpServletRequestWrapper(request, getUrlEncodingPattern(request)),
response);
}
}
@Override
public void logout(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication)
{
super.logout(new RemoveEncodingHttpServletRequestWrapper(request, getUrlEncodingPattern(request)), response, authentication);
}
@Override
protected Authentication createSuccessfulAuthentication(final HttpServletRequest request, final UserDetails user)
{
getUserService().setCurrentUser(getUserService().getUserForUID(user.getUsername()));
if (StringUtils.isNotEmpty(getUrlEncoderService().getUrlEncodingPattern()))
{
getCustomerFacade().rememberMeLoginSuccessWithUrlEncoding(getUrlEncoderService().isLanguageEncodingEnabled(),
getUrlEncoderService().isCurrencyEncodingEnabled());
}
else
{
getCustomerFacade().loginSuccess();
}
final RememberMeAuthenticationToken auth = new RememberMeAuthenticationToken(getKey(), user, user.getAuthorities());
auth.setDetails(getAuthenticationDetailsSource().buildDetails(request));
return auth;
}
@Override
protected String retrievePassword(final Authentication authentication)
{
return getUserService().getUserForUID(authentication.getPrincipal().toString()).getEncodedPassword();
}
protected String getUrlEncodingPattern(final HttpServletRequest request)
{
final String encodingAttributes = (String) request.getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES);
return StringUtils.defaultString(encodingAttributes);
}
protected UserService getUserService()
{
return userService;
}
@Required
public void setUserService(final UserService userService)
{
this.userService = userService;
}
protected CustomerFacade getCustomerFacade()
{
return customerFacade;
}
@Required
public void setCustomerFacade(final CustomerFacade customerFacade)
{
this.customerFacade = customerFacade;
}
protected CheckoutCustomerStrategy getCheckoutCustomerStrategy()
{
return checkoutCustomerStrategy;
}
@Required
public void setCheckoutCustomerStrategy(final CheckoutCustomerStrategy checkoutCustomerStrategy)
{
this.checkoutCustomerStrategy = checkoutCustomerStrategy;
}
protected UrlEncoderService getUrlEncoderService()
{
return urlEncoderService;
}
@Required
public void setUrlEncoderService(final UrlEncoderService urlEncoderService)
{
this.urlEncoderService = urlEncoderService;
}
protected StoreSessionFacade getStoreSessionFacade()
{
return storeSessionFacade;
}
@Required
public void setStoreSessionFacade(final StoreSessionFacade storeSessionFacade)
{
this.storeSessionFacade = storeSessionFacade;
}
protected CommonI18NService getCommonI18NService()
{
return commonI18NService;
}
@Required
public void setCommonI18NService(final CommonI18NService commonI18NService)
{
this.commonI18NService = commonI18NService;
}
protected SecureTokenService getSecureTokenService()
{
return secureTokenService;
}
@Required
public void setSecureTokenService(final SecureTokenService secureTokenService)
{
this.secureTokenService = secureTokenService;
}
}
bean 的声明方式如下:
<alias name="defaultRememberMeServices" alias="rememberMeServices"/>
<bean id="defaultRememberMeServices" class="com.sap.hybris.fs.storefront.security.AcceleratorRememberMeServices" >
<property name="userDetailsService" ref="originalUidUserDetailsService" />
<property name="key" value="fsstorefront" />
<property name="cookieName" value="fsstorefrontRememberMe" />
<property name="alwaysRemember" value="true" />
<property name="userService" ref="userService"/>
<property name="useSecureCookie" value="false"/>
<property name="customerFacade" ref="customerFacade"/>
<property name="checkoutCustomerStrategy" ref="checkoutCustomerStrategy"/>
<property name="urlEncoderService" ref="urlEncoderService"/>
<property name="storeSessionFacade" ref="storeSessionFacade"/>
<property name="commonI18NService" ref="commonI18NService"/>
<property name="secureTokenService" ref="secureTokenService"/>
</bean>
构造方法有问题吗?还是Spring配置的问题?感谢您对任何人的宝贵帮助。
最佳答案
它正在寻找默认构造函数,因此 <init>()
。您需要创建一个默认构造函数,或者在声明 bean 时使用构造函数参数。
在本例中,由于您要扩展现有的 TokenBasedRememberMeServices
类中,您需要使用相关的构造函数参数(key、userDefaultsService)声明 bean,而不是将它们作为属性注入(inject)。您的声明应如下所示:
<bean id="defaultRememberMeServices" class="com.sap.hybris.fs.storefront.security.AcceleratorRememberMeServices" >
<!-- constructor arguments -->
<constructor-arg index="0" value="fsstorefront"/>
<constructor-arg index="1" ref="originalUidUserDetailsService" />
<!-- rest of the properties -->
<property name="cookieName" value="fsstorefrontRememberMe" />
<property name="alwaysRemember" value="true" />
<property name="userService" ref="userService"/>
<property name="useSecureCookie" value="false"/>
<property name="customerFacade" ref="customerFacade"/>
<property name="checkoutCustomerStrategy" ref="checkoutCustomerStrategy"/>
<property name="urlEncoderService" ref="urlEncoderService"/>
<property name="storeSessionFacade" ref="storeSessionFacade"/>
<property name="commonI18NService" ref="commonI18NService"/>
<property name="secureTokenService" ref="secureTokenService"/>
</bean>
查看有关构造函数参数注入(inject)和 Spring 依赖注入(inject)的更多信息 here
关于java - 上下文初始化失败。 Spring错误NoSuchMethodException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42536369/
对于我的程序,目标是使用一堆接口(interface)并创建一个程序来进行测试并允许用户进行测试。我遇到的具体问题是 IQuestionFactory 接口(interface),它有助于在 Test
我刚刚读到有关反射的内容并决定尝试一下,但我似乎遇到了一个错误,我找不到原因。 我在一个类中得到了以下代码: String hashType = "md5"; Method method = Dige
我正在尝试使用反射来加载一个类的实例。当我尝试这样做时,我没有得到这样的方法异常。我已经检查并检查并重新检查。该构造函数显然确实存在。有人有什么想法吗?我之前在另一个代码基本相同的项目中成功使用过它,
这是连接两个关系的作业, import org.apache.hadoop.mapred.*; import org.apache.hadoop.conf.*; import org.apache.h
我正在尝试反序列化包含方法的 XML 文件。 片段看起来像: XMLDecoder decoder = new XMLDecoder(os); deSerializedObject = de
在我的 POM 中,我添加了依赖项 String 4.2.9.RELEASE、Spring boot 1.5.1.RELEASE 和 FasterXML/jackson 2.8.6,并出现以下错误:
在我的代码中有一个方法应该调用对象的方法doSomething。首先,不知道对象的类是否具有公共(public)方法。到目前为止,我使用了以下代码: try { Method method = c
我有以下具有静态方法的类,该方法采用 Class 类型的参数并生成一个 FunctionDescriptor。 public class NoInputFunctionDescriptorFactor
我正在使用 glassfish 3.1.2.2 服务器和 idea Ultimate Edition 11(在 Ubuntu 12.04 上)。当我部署我的耳朵项目时,有一个异常(exception)
所以我有一个定义了 2 个公共(public)方法的类。当我调用 getDeclaredMethods 时,然后循环结果,打印名称,两者都正确显示。所以不仅该方法存在,而且反射调用也找到了它。 但是当
每当使用 URLClassLoader 动态加载类时,当尝试执行使用自定义数据类型作为参数的方法时,我都会收到 NoSuchMethodException 异常。它查找具有标准类型(如 String
我正在尝试根据类和参数创建类的实例。用于创建此类的方法如下所示: @SuppressWarnings("unchecked") public Plugin instantiatePlugin(
我正在构建一个 JavaFx 应用程序,我想创建一个接收 GridPane 和 Node[] 以及添加到 Pane 中的项目数量的方法。但是,当我调用该方法时,我收到 NoSuchMethodExce
我有一个类如下: public class StreamEventSuccess { private final T event; public StreamEventSuccess(
我们正在开发一个动态类加载器项目,并尝试通过 URLClassLoader 调用动态加载类中的方法。它在 Eclipse 中运行时工作得很好,因此调用和动态加载的类被捆绑到两个不同的 jar 中,然后
我正在使用 Taylor 近似在 Java 中编写正弦函数的递归定义,但在运行代码时得到了 noSuchMethodException。这是我到目前为止所拥有的: public static void
我有一个 Android 应用程序。我正在使用反射来调用 CookieManager 的方法。 我在做什么: if (Build.VERSION.SDK_INT >= 21) { Method
我正在尝试编写一个表单,有一次有 2 个单选按钮询问此人的性别。我想要求至少按下一个按钮,否则他们就会 toast 。它们出现在 activity_main 中:
给出的类奖: public class Award { /* * */ // fields of the class Award() {
我在执行时得到一个NoSuchMethodException: operacionDTO.getClass().getMethod("setPrioridad").invoke(operacionDT
我是一名优秀的程序员,十分优秀!