我正在尝试通过 application-context.xml 中的声明在 Spring 中创建一个列表
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:component-scan base-package="com.example.check" />
<bean id="valueOptions">
<property name="valueList">
<list>
<value>Value A</value>
<value>Value B</value>
</list>
</property>
</bean>
当我尝试运行此代码时,我得到
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.get(Unknown Source)
atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:186)
我在尝试运行应用程序时收到 404。关于我做错了什么的任何想法?
更新
严重:向 org.springframework.beans.factory.annotation 的 java.util.concurrent.ConcurrentHashMap.get(Unknown Source) 的类 org.springframework.web.context.ContextLoaderListener java.lang.NullPointerException 的监听器实例发送上下文初始化事件的异常.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:186) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:857) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean. :829) 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory。doCreateBean(AbstractAutowireCapableBeanFactory.java:440) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory .support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton( DefaultSingletonBeanRegistry.java:220) 在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) 在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) at org.springframework .context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java :255) 在 org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) 在 org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) 在 org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791) 在 org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285) 在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase. java:150) 在 org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) 在 org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) 在 java.util .concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker .run(Unknown Source) at java.lang.Thread.run(Unknown Source)StandardContext.startInternal(StandardContext.java:5285) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)在 org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) 在 java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) 在 java.util.concurrent.FutureTask.run(Unknown Source ) 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 在 java.lang.Thread.run(Unknown Source) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)StandardContext.startInternal(StandardContext.java:5285) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)在 org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) 在 java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) 在 java.util.concurrent.FutureTask.run(Unknown Source ) 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 在 java.lang.Thread.run(Unknown Source) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)1559)在 org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) 在 java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) 在 java.util.concurrent.FutureTask.run( Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)1559)在 org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) 在 java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) 在 java.util.concurrent.FutureTask.run( Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
我之所以说它与列表创建有关,是因为如果我在我的 xhtml 文件中删除列表和相应的用法,则应用程序可以正常工作。