spring 配置 No Scope registered for scope 'singletone'

搞了好久了,求大神帮忙,异常信息如下:
Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'UserService' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: No Scope registered for scope 'singletone'
Caused by: java.lang.IllegalStateException: No Scope registered for scope 'singletone'
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:280)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:267)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1100)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:423)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1114)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1673)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)

spring 配置文件如下:

<?xml version="1.0" encoding="UTF-8"?>

<!-- dbcp连接池 -->  
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">  
    <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>  
    <property name="url" value="jdbc:mysql://localhost:3306/testdb"></property>  
    <property name="username" value="root"></property>  
    <property name="password" value="root"></property>  
    <!-- 最大连接数 -->  
    <property name="maxActive" value="100"></property>  
    <!-- 最大可空闲连接数 -->  
    <property name="maxIdle" value="30"></property>  
    <!-- 最大等待连接 -->  
    <property name="maxWait" value="500"></property>  
    <!-- 事务提交,true代表自动提交事物 -->  
    <property name="defaultAutoCommit" value="true"></property>  
</bean>  

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">  
    <property name="dataSource" ref="dataSource"></property>  
    <property name="hibernateProperties">  
        <props>  
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>  
            <prop key="hibernate.show_sql">true</prop>  
        </props>  
    </property>  
    <property name="mappingResources">  
        <list>
            <value>/WEB-INF/User.hbm.xml</value>
            <value>/WEB-INF/Num.hbm.xml</value>
        </list>  
    </property>  
</bean>  

<bean id="UserDAO" class="com.zw.dao.impl.UserDaoImpl" scope="singletone">  
    <property name="sessionFactory">  
         <ref bean="sessionFactory"/>  
    </property>  
</bean>

<bean id="NumDAO" class="com.zw.dao.impl.NumDaoImpl" scope="singletone">  
    <property name="sessionFactory">  
         <ref bean="sessionFactory"/>  
    </property>  
</bean>  

<bean id="UserService" class="com.zw.service.impl.UserServiceImpl">  
    <property name="userDao" ref="UserDAO"></property>  
</bean>

<bean id="NumService" class="com.zw.service.impl.NumServiceImpl">  
    <property name="numDao" ref="NumDAO"></property>  
</bean>  

<bean id="RegistAction" class="com.zw.action.RegistAction" scope="prototype">  
    <property name="userService" ref="UserService"></property>  
</bean>  

<bean id="LoginAction" class="com.zw.action.LoginAction" scope="prototype">  
    <property name="userService" ref="UserService"></property>  
</bean>  

<bean id="SumAction" class="com.zw.action.SumAction" scope="prototype">  
    <property name="numService" ref="NumService"></property>  
</bean>

1个回答

哥们spring 单例是:singleton 你打错了 多打了个e变成了 singletone

wshi215
fingerPower 擦。。我试过了,果然是的,谢谢兄弟啊。。。网上的demo看来不能直接copy。。
7 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐