当前位置: 代码迷 >> Eclipse >> javax.servlet.ServletException: org.springframework.beans.factory.NoSuchBeanDefi解决思路
  详细解决方案

javax.servlet.ServletException: org.springframework.beans.factory.NoSuchBeanDefi解决思路

热度:51   发布时间:2016-04-23 13:36:16.0
javax.servlet.ServletException: org.springframework.beans.factory.NoSuchBeanDefi
myeclipse10 ssh2框架错误求助: javax.servlet.ServletException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'userService' is defined

structs-config.xml
———————————————————————————————————————————————————————
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
  <data-sources />
  <form-beans >
  <form-bean name="loginForm" type="com.ssh.struts.form.LoginForm" />

  </form-beans>

  <global-exceptions />
  <global-forwards />
  <action-mappings >
  <action
  attribute="loginForm"
  input="/login.jsp"
  name="loginForm"
  path="/login"
  scope="request"
  type="com.ssh.struts.action.LoginAction">
  <set-property property="cancellable" value="true" />
  <forward name="success" path="/welcome.jsp" />
  </action>

  </action-mappings>

  <message-resources parameter="com.ssh.struts.ApplicationResources" />
</struts-config>
———————————————————————————————————————————————————————

applicationContext
———————————————————————————————————————————————————————
<?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:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">


<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/ssh"></property>
<property name="username" value="root"></property>
<property name="password" value="root"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/ssh/pojo/User.hbm.xml</value></list>
</property></bean>
<bean id="userDAO" class="com.ssh.dao.impl.UserDAOImpl">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="userServiceDAO"
class="com.ssh.service.impl.UserServiceDAOImpl">
<property name="userDAO">
<ref bean="userDAO" />
</property>
</bean>


</beans>

————————————————————————————————————————————————
  相关解决方案