2020/8/30 Daily News

Project scene:

Construction of ssm framework

Project scenario: configure the springmvc environment (the first step must be to introduce the jar package)

Problem Description:

  1. Error in header tag when creating xml file manually
<?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. The reason why application context not configured for this file is used in the spring framework

  2. Run tomcat error 404

  3. The action cannot jump to the corresponding controller

  4. Error creating bean with name'controller 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


Cause Analysis:

  1. Uniform Resource Identifier is not registered
  2. The file is not configured in the project
  3. The path setting error in the <welcome-file-list> tag causes the access page to not exist
  4. The database query was empty, the method returned null, and the logic behind did not return to the page, but directly returned null, causing an error.
  5. The service layer is not annotated, and the business implementation layer cannot be found
  6. SqlSessionFactory is not configured

solution:

1.1 Manually add

file–>setting–>languages ​​& frameworks–>Schemas and DTDs,
click on the "+" sign, and add the red part of the error report.Insert picture description here

1.2. Using software

In the red part alt+enter select Fetch external resource (to obtain external resources
) to solve

2. Add the file to the project

Enter the project structure, which is the project structure

Insert picture description here
Click modules->spring, the following prompts that applicationContext-transaction.xml is not configured. Insert picture description here
Click Modify and configure the unconfigured files to it to solve the problem.
Insert picture description here

3. Modify the path

Insert picture description here

4. Create a new page and jump based on logic

5. By adding @Service annotations to the business implementation layer

6.SqlSession is the key object of MyBatis, which is exclusive to perform persistence operations, similar to Connection in JDBC.

Insert picture description here

Guess you like

Origin blog.csdn.net/qq1350975694/article/details/108302502