0

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.web.context.ContextLoaderListener java.lang.NullPointerException at java.util.concurrent.ConcurrentHashMap.get(Unknown Source)atorg.springframework.beans.factory.annotationに送信する際の例外.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:186)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(BeanPostProcessors(AbstractAutowireCapableBeanFactory.java:857)at org.springframework :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)at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory。java:185)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)at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)atorg。apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)at org.apache.catalina.core.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)at org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1549)at 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) at org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1549)at 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) at org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1549)at 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)1559)org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1549)at java.util.concurrent.FutureTask $ Sync.innerRun(Unknown Source)at java.util.concurrent.FutureTask.run(不明なソース)at java.util.concurrent.ThreadPoolExecutor.runWorker(不明なソース)at java.util.concurrent.ThreadPoolExecutor $ Worker.run(不明なソース)at java.lang.Thread.run(不明なソース)1559)org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1549)at java.util.concurrent.FutureTask $ Sync.innerRun(Unknown Source)at java.util.concurrent.FutureTask.run(不明なソース)at java.util.concurrent.ThreadPoolExecutor.runWorker(不明なソース)at java.util.concurrent.ThreadPoolExecutor $ Worker.run(不明なソース)at java.lang.Thread.run(不明なソース)

リストの作成に関連していると言っているのは、リストとそれに対応するxhtmlファイルの使用法を削除すると、アプリケーションが正常に動作するためです。

4

1 に答える 1

1

xmlファイルでbean要素のclass属性を指定していません...

<bean id="valueOptions" class="your.package.ObjectName">
    <property name="valueList">
    <list>
        <value>Value A</value>
        <value>Value B</value>
    </list>
    </property>
</bean>

BeanがListオブジェクトの実装である場合、次のようなことができます。

<bean id="valueOptions" class="java.util.ArrayList">
    <constructor-arg>
        <list>
            <value>Value A</value>
            <value>Value B</value>                
        </list>
    </constructor-arg>
</bean>

または、util名前空間を使用します。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">


<util:list id="valueOptions" value-type="java.lang.String">
    <value>Value A</value>
    <value>Value B</value>   
</util:list>
于 2013-01-17T22:17:07.960 に答える