求助org.springframework.beans.factory.CannotLoadBeanClassException

新手上路,请多包涵

自学ssh框架,遇到如下问题,在网上查找很久不得所获,恳请各位指教
错误信息如下:

26-Nov-2017 10:52:35.207 信息 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext
26-Nov-2017 10:52:39.038 严重 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
 org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [service.impl.EmployeeServiceImpl] for bean with name 'employeeService' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: service.impl.EmployeeServiceImpl
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1385)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:641)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:609)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1484)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1007)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:741)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)

这是我的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"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
    <!--引入外部属性文件-->
    <context:property-placeholder location="classpath:jdbc.properties"/>
    <!--配置连接池-->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="${jdbc.driverClass}"/>
        <property name="jdbcUrl" value="${jdbc.url}"/>
        <property name="user" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
    </bean>
 
    <!--配置Hibernate相关的属性-->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
        <!--注入连接池-->
        <property name="dataSource" ref="dataSource"/>
        <!--配置Hibernate的属性-->
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.format_sql">true</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
            </props>
        </property>
        <!--加载Hibernate中的映射文件-->
        <property name="mappingResources">
            <list>
                <value>domain/Department.hbm.xml</value>
                <value>domain/Employee.hbm.xml</value>
            </list>
        </property>
    </bean>
    <!--配置Action的类-->
    <bean id="employeeAction" class="action.EmployeeAction" scope="prototype"><!--多例的-->
        <property name="employeeService" ref="employeeService"/>
    </bean>
 
    <!--配置业务层的类-->
    <bean id="employeeService" class="service.impl.EmployeeServiceImpl">
        <property name="employeeDao" ref="employeeDao"/>
    </bean>
 
    <!--配置DAO的类-->
    <bean id="employeeDao" class="dao.impl.EmployeeDaoImpl">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
 
    <!--配置事务管理器-->
    <bean id="transactionManger" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
 
    <!--开启注解事务-->
    <tx:annotation-driven transaction-manager="transactionManger"/>
</beans>

这个是EmployeeImpl类

package service.impl;
 
import dao.EmployeeDao;
import service.EmployeeService;
 
/**
 * 员工管理业务的实现类
 */
public class EmployeeServiceImpl implements EmployeeService{
    /**
     * 注入DAO层
     */
    private EmployeeDao employeeDao;
 
    public void setEmployeeDao(EmployeeDao employeeDao) {
        this.employeeDao = employeeDao;
    }
}

我已经检查过了,类名没有写错,我怀疑是jar包导入错误的问题,但是不知道是哪个jar包,以下是我的jar包
图片描述

阅读 5.5k
1 个回答

加个@Service注解试试

@Service
public class EmployeeServiceImpl implements EmployeeService{
 //omitted
推荐问题