Spring handlerInterceptorAdapter 的自动布线失败。
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pathInterceptor':
Injection of autowired dependencies failed; nested exception is org.spring.framework.beans.factory.BeanCreationException:
Could not autowire field:
private java.lang.String com.mine.spring.interceptors.PathInterceptor.vendor; nested exception is java.lang.NullPointerException
INFO | jvm 1 | 2017/08/09 23:29:41 | at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
INFO | jvm 1 | 2017/08/09 23:29:41 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1218)
INFO | jvm 1 | 2017/08/09 23:29:41 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
INFO | jvm 1 | 2017/08/09 23:29:41 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
INFO | jvm 1 | 2017/08/09 23:29:41 | at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
INFO | jvm 1 | 2017/08/09 23:29:41 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
INFO | jvm 1 | 2017/08/09 23:29:41 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
这是来自 springxml 文件的狙击手
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:c="http://www.springframework.org/schema/c"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
。
<bean id="vendor" class="java.lang.String" c:_0="MyVendor"/>
<mvc:interceptors>
<bean class="com.mine.spring.interceptors.PathInterceptor" />
</mvc:interceptors>
这是 java 类的代码片段
@Component
public class PathInterceptor extends HandlerInterceptorAdapter {
@Autowired
@Qualifier("vendor")
private String vendor;
思潮?
我认为你的字符串豆(呵呵(语法是错误的。
<bean id="vendor" class="java.lang.String">
<constructor-arg value="MyVendor"/>
</bean>
在我的上下文扫描中,有某种自定义自动布线库弄乱了标准的自动布线。 除了找出自定义库并将其删除以使自动布线正常工作之外,我没有再追踪它了。