2020/8/30 日报

项目场景:

ssm框架的搭建

项目场景:配置springmvc环境(第一步一定先要引入jar包)

问题描述:

  1. 手动创建xml文件时头标签报错
<?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:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       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/aop 
        http://www.springframework.org/schema/aop/spring-aop.xsd">

</beans>
  1. application context not configured for this file于spring框架使用中的原因

  2. 运行tomcat报错404

  3. action跳转不到相应的controller

  4. Error creating bean with name ‘控制器名字’

  5. org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'loginController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'userMapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file [F:\gradute-students\gradute-student\graduate-student-mvc\out\artifacts\graduate_student_mvc_war_exploded\WEB-INF\classes\com\d\mapper\UserMapper.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sqlSessionFactory' available


原因分析:

  1. 统一资源标识符没有注册
  2. 没有配置该文件到项目中
  3. < welcome-file-list > 标签中路径设置错误导致访问页面不存在
  4. 数据库查询为空,方法返回了null,后面的逻辑并没有返回到页面,而是直接返回了null,导致出错。
  5. service层没有加注解,找不到业务实现层
  6. 没有配置SqlSessionFactory

解决方案:

1.1 手动添加

file–>setting–>languages & frameworks–>Schemas and DTDs
点击“+”号,将报错的红色部分添加进去就行了。在这里插入图片描述

1.2. 利用软件

在红色的部分alt+enter 选择Fetch external resource(获取外部资源
)即可解决

2.添加该文件到项目中

进入project structure也就是项目结构中

在这里插入图片描述
点击modules->spring,下边提示applicationContext-transaction.xml没有配置在这里插入图片描述
点击修改将没配置的文件配置到其中即可解决
在这里插入图片描述

3.修改路径

在这里插入图片描述

4. 根据逻辑新建页面并跳转

5. 通过在业务实现层添加@Service注解

6.SqlSession是MyBatis的关键对象,是执行持久化操作的独享,类似于JDBC中的Connection.

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq1350975694/article/details/108302502