控制台报错:Instantiation of bean failed;
Error creating bean with name 'diService' defined in class path resource [applicationContext.xml]: Instantiation of bean failed;
Solution:
Spring依赖注入的两种方式只能选择一种,即使创建未使用也会出现错误。
SSM中JSP页面跳转的问题
Solution:![/](https://img-blog.csdnimg.cn/20191030172857982.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwOTk0MjYw,size_16,color_FFFFFF,t_70)
SSM中静态资源存储的问题:
Solution:
在Dao层对应的Mapper映射表还是空的时候,不要先把Mapper映射表写在mybatis-config.xml中;否则控制台报错
切记在spring-servlet.xml中声明上下文context的controller层, 而在applicationContext.xml中声明service层,若位置不匹配则会出现错误。
即:
Solution:
<context:component-scan base-package="controller"/>
controller要在spring-servlet.xml中声明!
<!-- 使用扫描机制扫描service包 -->
<context:component-scan base-package="service"/>
<!-- Mapper代理开发,使用Spring自动扫描MyBatis的接口并装配
(Spring将指定包中所有被@Mapper注解标注的接口自动装配为MyBatis的映射接口) -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- mybatis-spring组件的扫描器,dao只需要接口(接口方法与SQL映射文件中的相同) -->
<property name="basePackage" value="dao"/>
<!-- 注入sqlSessionFactory -->
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
dao、service要在applicationContext.xml中声明!