Tag Archives: mybatis

springboot sqlserver druid reward: validateConnection false

The exception information is as follows:

java.sql.SQLException: validateConnection false
	at com.alibaba.druid.pool.DruidAbstractDataSource.validateConnection(DruidAbstractDataSource.java:1418)
	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1733)
	at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2801)
Caused by: java.lang.NullPointerException: null
	at com.alibaba.druid.wall.WallProvider.checkInternal(WallProvider.java:707)
	at com.alibaba.druid.wall.WallProvider.check(WallProvider.java:584)
	at com.alibaba.druid.wall.WallFilter.checkInternal(WallFilter.java:826)
	at com.alibaba.druid.wall.WallFilter.check(WallFilter.java:821)
	at com.alibaba.druid.wall.WallFilter.statement_execute(WallFilter.java:454)
	at com.alibaba.druid.filter.FilterChainImpl.statement_execute(FilterChainImpl.java:3008)
	at com.alibaba.druid.filter.FilterAdapter.statement_execute(FilterAdapter.java:2484)
	at com.alibaba.druid.filter.FilterEventAdapter.statement_execute(FilterEventAdapter.java:188)
	at com.alibaba.druid.filter.FilterChainImpl.statement_execute(FilterChainImpl.java:3008)
	at com.alibaba.druid.proxy.jdbc.StatementProxyImpl.execute(StatementProxyImpl.java:147)
	at com.alibaba.druid.pool.vendor.MSSQLValidConnectionChecker.isValidConnection(MSSQLValidConnectionChecker.java:50)
	at com.alibaba.druid.pool.DruidAbstractDataSource.validateConnection(DruidAbstractDataSource.java:1398)

Follow this method: com.alibaba.druid.pool.druidabstractdatasource.validateconnection

result = validConnectionChecker.isValidConnection(conn, validationQuery, validationQueryTimeout);

Find the exception of this line of code and enter this method

Find the method of this implementation class (because it is SQL server)

public boolean isValidConnection(final Connection c, String validateQuery, int validationQueryTimeout) throws Exception {
        if (c.isClosed()) {
            return false;
        }

        Statement stmt = null;

        try {
            stmt = c.createStatement();
            if (validationQueryTimeout > 0) {
                stmt.setQueryTimeout(validationQueryTimeout);
            }
            stmt.execute(validateQuery);
            return true;
        } catch (SQLException e) {
            throw e;
        } finally {
            JdbcUtils.close(stmt);
        }
    }

Finally, it is found that the method parameter validatequery is null, so a null pointer is reported. Let’s go back and see why it is null

protected volatile String                          validationQuery                           = DEFAULT_VALIDATION_QUERY;

Class defines that validationquery is equal to default_ VALIDATION_ Query, and default_ VALIDATION_ Query initialization is defined as null. In fact, this parameter comes from the springboot configuration file

Add the following configuration in the springboot data source configuration file:

druid:
                        validation-query: SELECT 1

Just do it!

PS, data source configuration:

driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://IP:PORT;DatabaseName=database name
username: username
password: password
druid:
    validation-query: SELECT 1

The SSM framework adds the mybatis paging plug-in to start the error report

1、 Error

pom.xml

Mybatis configuration

start the server: an error is reported

2. The cause of the error
1. There is no problem with various configurations
2. It is considered that jar packages conflict. Changing various jar packages has no effect
3. Finally, type
* * manually and start it successfully

3、 Analyze the possibility of errors

1. The idea is used for a long time and the cache is too large
3. There may be problems with character encoding such as spaces when copying

Datasource bean injection failed, with startup error

springboot2.X+sharding-jdbc 3.0+mybatis 2.1.0

When PageHelper 1.3.0 was introduced, the project could not start

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'dataSource', defined in class path resource [io/shardingsphere/shardingjdbc/spring/boot/SpringBootConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

Solution:
1.
automatically configure the priority problem. Add the org.apache.shardingsphere package path in @ componetscan to improve the scanning priority and solve the problem
@ componentscan (value = {“io. Shardingsphere. *” and “your other package names”})

2. Automatic injection of data source is prohibited

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})

Manual injection
https://www.cnblogs.com/inbeijing/p/14419108.html

[Solved] Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException

The following errors are reported using Mybatis.

Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is ‘com/kq/dao/UserMapper.xml’. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘UserMap’. Cause: java.lang.ClassNotFoundException: Cannot find class: UserMap
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:122)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:99)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:78)
… 25 more
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is ‘com/kq/dao/UserMapper.xml’. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘UserMap’. Cause: java.lang.ClassNotFoundException: Cannot find class: UserMap
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:123)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:95)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:377)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:120)
… 27 more
Caused by: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘UserMap’. Cause: java.lang.ClassNotFoundException: Cannot find class: UserMap
at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:118)
at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:102)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:138)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:131)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:121)
… 30 more
Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘UserMap’. Cause: java.lang.ClassNotFoundException: Cannot find class: UserMap
at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:120)
at org.apache.ibatis.builder.BaseBuilder.resolveAlias(BaseBuilder.java:149)
at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:116)
… 34 more
Caused by: java.lang.ClassNotFoundException: Cannot find class: UserMap
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:196)
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:89)
at org.apache.ibatis.io.Resources.classForName(Resources.java:261)
at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:116)
… 36 more

 

Solution:

1. first look at whether you have used the ResultMap to define the returned result set, if so, look at your configuration of the xmlSQL statement mapping the return set result type is resultType or resultMap type, if it is the resultType type, then it is right, change the resultType to resultMap type, it should be right. 2.
The reason is: when you use the custom resultMap for the returned result set, you did not change the SQL statement in the xml file of the resultType to resultMap, resulting in not finding the id of the result set of your custom resultMap, that is, Cause: java.lang. ClassNotFoundException: Cannot find class: <here is the id name of your custom resultMap>.

Error querying database.Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource.

Record the problems encountered in the learning process of Java mybatis framework

1. An exception occurred while building the first mybatis project:

Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: 

Error querying database. Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. 
Cause: java.lang.ClassNotFoundException: Cannot find class: com.mysql.cj.jdbc.Driver

Solution: the MySQL connector Java driver version is used incorrectly
I use MySQL version 8.0.22

import the driver of version 5.1.23, and the dependency declared in pom.xml file is

<dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.23</version>
    </dependency>

The two versions do not correspond, so the driver error cannot be found.
the solution is to download the driver of version relative to, that is, the driver of version 8.0.22. The official website address is version 8.0.22
and then change the dependency in the POM file to:

<!--MySQL-->
<dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>8.0.22</version>
    </dependency>

Another point is that the POM file should include not only driver dependencies, but also mybatis dependencies

<!--mybatis-->
<dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.4.5</version>
    </dependency>

Mybatis Error setting non null for parameter #15 with JdbcType null Could not set parameters for

Caused by: org.apache.ibatis.type.TypeException: Error setting non null for parameter #15 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (15 > number of parameters, which is 14).
	at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:71)
	at com.baomidou.mybatisplus.core.MybatisDefaultParameterHandler.setParameters(MybatisDefaultParameterHandler.java:227)
	... 88 more
Caused by: java.sql.SQLException: Parameter index out of range (15 > number of parameters, which is 14).

If a comment SQL fragment exists in the SQL code, the #{} parameter cannot be used in the comment SQL fragment. As follows:

        on t1.dealer_code = t4.dealer_code
        -- left join (
        --     select
        --         ads_code
        --        ,sum(case when car like '%MM%' or model = 'MM' then ss_num else 0 end) as ws_MM_num
        --     from abc_assss_ss
        --     where seq = 1 and count_date between '2021-04-01' and '2021-06-30'
        --     group by
        --         dealer_code
        --     )t2
        -- on t1.asd_code = t2.ads_code
        )
        select
      ~~~
      If you replace the between and with the parameter between #{start_time} and #{end_time}, it will report this error, hope it can solve your problem

org.apache.ibatis.type.TypeException: Error setting non null for parameter #4 with JdbcType null

preface

        The spring boot project uses the mybatis plus framework.

Phenomenon

        When I used mappr to execute the method updatebyid again, the following error occurred

nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='et.props', mode=IN, javaType=class java.lang.Object, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #4 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #4 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: org.postgresql.util.PSQLException: No hstore extension installed.
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='et.props', mode=IN, javaType=class java.lang.Object, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #4 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #4 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: org.postgresql.util.PSQLException: No hstore extension installed.

Problem location

        Through the literal meaning of the exception, we can understand it as a mybatis type error.

        Following up with debug, we found that an exception occurred when setting typehandler for one of the fields, indicating that there is no type that can identify the field.

  Cause analysis

        We now check the type of this field in the entity class and find that it is a map type

          View the type of this field setting in the database  , You can see that the JSON type is stored in the database

  Solution

        Set typehandler and JDBC type for entity class

@TableField(el = "props,jdbcType=OTHER,typeHandler=com.embracesource.cloud.fsgw.entity.HashMapJsonTypeHandler")
private Map<String, Object> props;

        Hashmapjsontypehandler class

import com.alibaba.fastjson.JSON;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.postgresql.util.PGobject;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

public class HashMapJsonTypeHandler extends BaseTypeHandler<Map<String,Object>> {
    @Override
    public void setNonNullParameter(PreparedStatement ps, int i, Map<String,Object> parameter,
                                    JdbcType jdbcType) throws SQLException {
        PGobject jsonObject = new PGobject();
        jsonObject.setType("json");
        jsonObject.setValue(JSON.toJSONString(parameter));
        ps.setObject(i, jsonObject);
    }

    @Override
    public Map<String,Object> getNullableResult(ResultSet rs, String columnName)
            throws SQLException {

        return JSON.parseObject(rs.getString(columnName), HashMap.class);
    }

    @Override
    public Map<String,Object> getNullableResult(ResultSet rs, int columnIndex) throws SQLException {

        return JSON.parseObject(rs.getString(columnIndex), HashMap.class);
    }

    @Override
    public Map<String,Object> getNullableResult(CallableStatement cs, int columnIndex)
            throws SQLException {

        return JSON.parseObject(cs.getString(columnIndex), HashMap.class);
    }
}

         Start the project again and find the problem to be solved

About the error querying database. Cause: java.lang.nullpointerexception reported in mybatis

There is such a problem when upgrading the previous project today

### Error querying database.  Cause: java.lang.NullPointerException
### The error may exist in file [/Users/xxxx/IDEA-Pr/Hire/UserInformation/target/classes/mapper/EmployeeDao.xml]
### The error may involve com.app.hire.dao.EmployeeDao.selectEmployee
### The error occurred while handling results
### SQL: select         e.user_id,         e.name,         e.age,         e.sex,         e.employee_desc,         e.create_time,         e.last_edit_time,         e.phone,         e.address,         e.image,         a.area_id,         a.area_name,         a.area_desc         from tb_area a,tb_employee e         where a.area_id=e.area_id and e.user_id=?
### Cause: java.lang.NullPointerException] with root cause

The wrong information as like as two peas in the mapper file, I ran the code that didn’t upgrade. The result is the same code. It can’t be used here. The springboot version of the previous code is 2.3.7.RELEASE. The current version is 2.2.2.RELEASE
after two hours of crazy inquiries. Finally, the problem is found
in our mapper file, if you want to perform a joint query, you will write a resultmap to put the query results. The class to be jointly queried has an attribute javatype. Set the real class of the object as shown in the figure below

but it is strange that my previous version can run without this javatype, As a result, the version has been reduced, but it can’t run. Do you have a boss to help answer the reason?Is it because the springboot version has been upgraded?

Conclusion: when writing resulmap, you’d better add javatype, otherwise there’s no place to find such errors.

Error reporting: error building sqlsession

Error details:

Error building SqlSession.

The error may exist in com/lengzher/Dao/UserMapper.xml

Cause: org.apache.ibatis.builder.builderexception: error parsing SQL mapper configuration. Cause: org.apache.ibatis.builder.builderexception: error creating document instance. Cause: com.sun.org.apache.xerces.internal.impl.io.malformedbytesequenceexception: byte 1 of UTF-8 sequence of 1 byte is invalid.

Problem solving:

The error may exist in COM/lengzhe/Dao/usermapper.xml indicates that the problem may be wrong in usermapper.xml, such as wrong path, more spaces, etc. But our mistakes are more than that; The following error log writes: byte 1 of 1-byte UTF-8 sequence is invalid. The description is that Chinese appears in usermapper.xml!!! Note: do not appear Chinese in usermapper.xml, even comments!!! Delete the Chinese in usermapper.xml. The problem is solved

[Solved] Error resolving template template might not exist or might not be accessible

Resolving error template template may not exist or may not be accessible

    1. there may be a problem with your controller annotation
    1. the difference between controller annotation and restcontroller annotation. Thymeleaf configures the corresponding path in the properties or YML configuration file
    1. about

      1. properties spring.web.resources.static-locations=classpath:/static/, classpath:/templates/ yml
	spring:
      thymeleaf:
        # thymeleaf The directory where the page is stored
        prefix: classpath:/templates/

Return path problem
there is no Maven clear in the return path

[Solved]Org.springframework.beans.factory.nosuchbeandefinitionexception error reported

Problems:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.pri.dao.UserDao’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Problem Description:
No match to com.pri.dao.UserDao
Error code:

14-Aug-2021 09:57:18.405 Warning [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath
14-Aug-2021 09:57:18.445 Warning [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext
14-Aug-2021 09:57:20.787 Warning [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': 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 'userDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.pri.dao.UserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:401)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:292)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4861)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
	at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1730)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:484)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:433)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468)
	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
	at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1408)
	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324)
	at sun.rmi.transport.Transport$1.run(Transport.java:200)
	at sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'userDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.pri.dao.UserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1307)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
	... 62 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.pri.dao.UserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1717)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1273)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
	... 75 more

14-Aug-2021 09:57:20.797 信息 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Closing Spring root WebApplicationContext

Solution:
first, check whether the Dao layer (mapper layer) has the annotation @ repository. Only when this annotation is added can this class be loaded during spring initialization.
Second, check whether the annotation is scanned in the spring configuration file. Note that the mappercannerconfigurer should be used to scan the interface of Dao layer

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.pri.dao"></property>
</bean>

instead of

<context:component-scan base-package="com.pri.dao"></context:component-scan>

This tag scans the basic components and the other three components @service @component @controller
the author made this mistake and found it after looking for a long time
so we must pay attention to the details and pay attention to the details
If an error is reported, you should analyze it yourself first. For example, if you can’t find the corresponding userdao and have comments on this class, you can only analyze the problem in the spring.xml configuration file and the scanning package
I hope I can help you!!!