当前位置:编程学习 > JAVA >>

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '

=======================applicationContext.xml==========================================
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">


<bean id="ds" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver">
</property>
<property name="url"
value="jdbc:oracle:thin:@localhost:1521:orcl">
</property>
<property name="username" value="scott"></property>
<property name="password" value="gy"></property>
</bean>
<bean id="sf"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="ds" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<prop key="hibernate.show_sql">
true
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/accp/library/entity/Books.hbm.xml</value></list>
</property>
</bean>
<!--dao -->
<bean id="bookDao" class="com.accp.library.dao.impl.BookDaoImpl">
 <property name="sessionFactory" ref="sf"/>
</bean>
<!-- biz -->
<bean id="bookBiz" class="com.accp.library.biz.impl.BookBizImpl">
<property name="bookDao" ref="bookDao"></property>
</bean>
<!-- action -->
<bean id="bookAction" class="com.accp.library.action.BookAction">
 <property name="bookBiz" ref="bookBiz"></property>
</bean>
</beans>


================================web.xml====================================================
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <filter>
   <filter-name>struts2</filter-name>
   <filter-class>
   org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
   </filter-class>
  </filter>
  <filter-mapping>
   <filter-name>struts2</filter-name>
   <url-pattern>/*</url-pattern>
  </filter-mapping>
  
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  
  </web-app>
--------------------编程问答-------------------- 报错是没有配置相应的Bean,直接检查一下配置对不对。 --------------------编程问答-------------------- applicationContext.xml找了,配置了
在配置OpenSessionInViewFilter时候必须配置init-param<filter>
    <filter-name>OpenSessionInViewFilter</filter-name>
   <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
   <init-param>
     <param-name>sessionFactoryBeanName</param-name>
     <param-value>sf</param-value>
   </init-param>
  </filter>
  <filter-mapping>
    <filter-name>OpenSessionInViewFilter</filter-name>
   <url-pattern>/*</url-pattern>
  </filter-mapping>
补充:Java ,  Web 开发
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,