尝试使用Spring Session和Aspectj将会话序列化后的@Autowired
字段重新连接到Redis。
这是豆子:
@UIScope()
@SpringComponent(value = AboutView.VIEW_NAME)
@SpringView(name = AboutView.VIEW_NAME)
//
@Configurable(autowire = Autowire.BY_NAME, value = AboutView.VIEW_NAME, dependencyCheck = false, preConstruction = true)
public class AboutView extends AbstractView {
public static final String VIEW_NAME = "butterfly-effect-frontend-system:about";
private Table tableFrontEndInformation;
private GridLayout backendLayout;
private GridLayout frontendLayout;
@Autowired
private transient DiscoveryClient discoveryClient;
这个bean使用@Configurable和bean定义的名称(值)。不幸的是,方面是创建一个带有空bean名称的BeanWiringInfo
,因为名称是必需的,会引发错误。
@Configurable(autowire = Autowire.BY_NAME, value = AboutView.VIEW_NAME, dependencyCheck = false, preConstruction = true)
由于以下由AnnotationBeanWiringInfoResolver调用的构造函数而发生错误
/**
* Create a new BeanWiringInfo that points to the given bean name.
* @param beanName the name of the bean definition to take the property values from
* @param isDefaultBeanName whether the given bean name is a suggested
* default bean name, not necessarily matching an actual bean definition
* @throws IllegalArgumentException if the supplied beanName is {@code null},
* is empty, or consists wholly of whitespace
*/
public BeanWiringInfo(String beanName, boolean isDefaultBeanName) {
Assert.hasText(beanName, "'beanName' must not be empty");
this.beanName = beanName;
this.isDefaultBeanName = isDefaultBeanName;
}
AnnotationBeanWiringInfoResolver从此代码中实例化BeanWiringInfo:
protected BeanWiringInfo buildWiringInfo(Object beanInstance, Configurable annotation) {
if (!Autowire.NO.equals(annotation.autowire())) {
return new BeanWiringInfo(annotation.autowire().value(), annotation.dependencyCheck());
}
else {
if (!"".equals(annotation.value())) {
// explicitly specified bean name
return new BeanWiringInfo(annotation.value(), false);
}
else {
// default bean name
return new BeanWiringInfo(getDefaultBeanName(beanInstance), true);
}
}
}
这是错误:
Caused by: java.lang.IllegalArgumentException: 'name' must not be null
at org.springframework.util.Assert.notNull(Assert.java:115) ~[spring-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.BeanFactoryUtils.transformedBeanName(BeanFactoryUtils.java:72) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.transformedBeanName(AbstractBeanFactory.java:1109) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:970) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at com.vaadin.spring.internal.SpringViewDisplayPostProcessor.postProcessAfterInitialization(SpringViewDisplayPostProcessor.java:66) ~[classes/:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:423) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1594) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:400) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.wiring.BeanConfigurerSupport.configureBean(BeanConfigurerSupport.java:142) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect.configureBean(AnnotationBeanConfigurerAspect.aj:63) ~[spring-aspects-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.aspectj.AbstractDependencyInjectionAspect.ajc$before$org_springframework_beans_factory_aspectj_AbstractDependencyInjectionAspect$1$e854fa65(AbstractDependencyInjectionAspect.aj:79) ~[spring-aspects-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at com.scipionyx.butterflyeffect.frontend.configuration.ui.view.AboutView.<init>(AboutView.java:72) ~[classes/:na]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_45]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_45]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_45]
at java.lang.reflect.Constructor.newInstance(Constructor.java:422) ~[na:1.8.0_45]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
... 107 common frames omitted
有谁知道这个配置会出现什么问题?
非常感谢您的帮助。
答案 0 :(得分:0)
我仍然试图了解原因,但似乎从@Configuration中移除$result = $this->getEntityManager()->getConnection()->fetchAll($sql)
似乎可以解决问题。
现在班级看起来像这样:
autowire = Autowire.BY_NAME