搭建 ssm 环境

 <!-- 引入外部jdbc配置文件 -->

<context:property-placeholder location="classpath:dbconfig.properties"></context:property-placeholder>

像这种类型的都要加上 classpath: 才能正常找到,idea编辑时不加也能访问到,但是要让程序运行起来还找到就必须加上



<!-- 配置和mybatis的整合 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <!-- 指定mybatis全局配置文件的位置 -->
    <property name="configLocation" value="classpath:mybatis-config.xml"></property>
    <property name="dataSource" ref="pooledDataSource"></property>
    <!-- 指定mybatis mapper文件的位置 -->
    <property name="mapperLocations" value="classpath:mapper/*.xml"></property>
</bean>
这里 mapper 文件的位置进行了路径修改来解决异常

pagehelper插件使用:

这里 

EmployeeService employeeService;
因为没有注入 所以导致了空指针异常 注入后就正常运行了




出现了
org.springframework.beans.factory.BeanCreationException: Error creating bean with name  .......... (省略)
Cause: java.lang.ClassNotFoundException: Cannot find class: com.github.pagehelper.PageInterceptor

的错误,发现是因为idea下没有将 pagehelper的jar包导入web项目中,导入方法:





原文地址:https://www.cnblogs.com/kinome/p/9104774.html