Giovani-Github / ssmDemo1

SSM框架整合练习项目 来自《2017-7黑马49期web》

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

项目简介

SSM框架整合练习项目 来自《2017-7黑马49期web》

项目总结

1. 项目搭建

  • 错误1:找不到DataSource 2018年7月10日12:58:51

     严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
     org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in file [F:\IdeaProjects\ssmDemo1\out\artifacts\ssmDemo1_war_exploded\WEB-INF\classes\spring\applicationContext-trans.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSource' is defined
    

由于spirng是使用分离配置文件的方式进行搭建,所以需要在web.xml里面需要进行配置加载

       <!-- 配置spring -->
       <context-param>
           <param-name>contextConfigLocation</param-name>
           <param-value>classpath:spring/applicationContext-*.xml</param-value>
       </context-param>

       <!-- 配置监听器加载spirng-->
       <listener>
           <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
       </listener>

但是因为 applicationContext-dao.xml 在创建的时候,少了.xml

所以导致找不到applicationContext-dao.xml,最终引起错误1

2. 项目编写:实现页面查询条件初始化

  • 错误2:在com.giovani.crm.controller.CustomerController层,无法注入com.giovani.crm.service.BaseDictService 2018年7月10日16:35:49

    严重: StandardWrapper.Throwable
    
     org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customercom.giovani.crm.controller.CustomerController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.giovani.crm.service.com.giovani.crm.service.BaseDictService com.giovani.crm.com.giovani.crm.controller.CustomerController.Customercom.giovani.crm.controller.CustomerController.com.giovani.crm.service.BaseDictService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.giovani.crm.service.com.giovani.crm.service.BaseDictService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    
    

    由于 @Autowired 注解是根据类型注入,不是根据名称注入。所以他在找 com.giovani.crm.service.BaseDictService 的时候会根据他的类型,找到他的实现类进行注入

    但是因为 com.giovani.crm.service.BaseDictService 的实现类 com.giovani.crm.service.impl.BaseDictServiceImpl 没有加上 @Service 注解,导致 com.giovani.crm.controller.CustomerController 无法注入 com.giovani.crm.service.BaseDictService 从而引发 错误2

3. 静态页面显示不正常

  • 错误3:加入静态资源(html/css/js)后,页面显示不正常 Aaron Swartz

4.encodingFilter报错

需加入 tomcat/lib/servlte-api.jar

About

SSM框架整合练习项目 来自《2017-7黑马49期web》


Languages

Language:Java 77.7%Language:CSS 20.5%Language:JavaScript 1.8%