首页 新闻 搜索 专区 学院

SSH框架的错误谁能给看看谢谢

0
悬赏园豆:10 [已解决问题] 解决于 2014-02-23 19:30

这是页面的错误。

 

这是控制台的错误

 

二月 23, 2014 6:16:05 下午 org.apache.struts2.dispatcher.Dispatcher error
SEVERE: Exception occurred during processing request: Unable to instantiate Action, com.action.Move_bookAction, defined for 'book' in namespace '/'Error creating bean with name 'com.action.Move_bookAction': Injection of resource methods failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'bookDaoImpl' is defined
Unable to instantiate Action, com.action.Move_bookAction, defined for 'book' in namespace '/'Error creating bean with name 'com.action.Move_bookAction': Injection of resource methods failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'bookDaoImpl' is defined
at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:316)
at com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:397)
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:194)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)

 

 

 

------------------这是Action:---------------------

package com.dao.impl;

 

import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;


import com.dao.Move_bookDao;
import com.entity.Move_booking;
@Repository(value="bookDaoImpl")
public class Move_bookDaoImpl extends HibernateDaoSupport implements Move_bookDao{

@Override
public void addMove_book(Move_booking book) {
// TODO Auto-generated method stub
this.getHibernateTemplate().save(book);


}
@Resource(name="sf")
public void setSf(SessionFactory sf){
super.setSessionFactory(sf);

}

}

 

 

----------这是MoveBookDaoimpl----------------

package com.dao.impl;

 

import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;


import com.dao.Move_bookDao;
import com.entity.Move_booking;
@Repository(value="bookDaoImpl")
public class Move_bookDaoImpl extends HibernateDaoSupport implements Move_bookDao{

@Override
public void addMove_book(Move_booking book) {
// TODO Auto-generated method stub
this.getHibernateTemplate().save(book);


}
@Resource(name="sf")
public void setSf(SessionFactory sf){
super.setSessionFactory(sf);

}

}

 

问题补充:

--------------------------这是applicationContext.xml----------------

<?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:context="http://www.springframework.org/schema/context"

xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
">

<context:component-scan base-package="comm" />
<!-- 配置数据源 -->
<bean id="ds" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl" />
<property name="username" value="David" />
<property name="password" value="qweqwe" />
</bean>
<!-- SessionFactory -->
<bean id="sf" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="ds"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9iDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="packagesToScan" value="com.entity" />

</bean>


</beans>

漫天de光的主页 漫天de光 | 初学一级 | 园豆:23
提问于:2014-02-23 18:19
< >
分享
最佳答案
0

<context:component-scan base-package="comm" /> 配置错误了

漫天de光 | 初学一级 |园豆:23 | 2014-02-23 19:30
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册