项目场景:
ssm框架的搭建
项目场景:配置springmvc环境(第一步一定先要引入jar包)
问题描述:
- 手动创建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>
-
application context not configured for this file于spring框架使用中的原因
-
运行tomcat报错404
-
action跳转不到相应的controller
-
Error creating bean with name ‘控制器名字’
-
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
原因分析:
- 统一资源标识符没有注册
- 没有配置该文件到项目中
- < welcome-file-list > 标签中路径设置错误导致访问页面不存在
- 数据库查询为空,方法返回了null,后面的逻辑并没有返回到页面,而是直接返回了null,导致出错。
- service层没有加注解,找不到业务实现层
- 没有配置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没有配置
点击修改将没配置的文件配置到其中即可解决