problem 1
is in the Mapper layer and it needs to be annotated with @mapper, but then someone put @respository online and it gets mixed up and it could be either one. It’s always going to be @mapper. Add the annotations, but if the Mapper layer in the configuration main class SpringBootMybatisApplication inside there is no need for @ MapperScan (” com. Example. Demo. Mapper “) scans annotations, add scan to the configuration class notes mean under this package all annotations into Mapper.
problem 2
SpringBoot project created with STS, where the configuration file defaults to application.properties, where the data source is typically configured. But want to play this file, you must add @ EnableAutoConfiguration to configure the main class (exclude = {DataSourceAutoConfiguration. Class}) automatic injection, otherwise the configuration in the configuration file is invalid. Failed to configure a DataSource: ‘URL’ attribute is not specified and no embedded DataSource could be configured. Error p>
but if this annotation is added at this time,
is dependent on the jar package in Mybatis
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</ version>
</dependency>
problem three
Automatic injection of SqlSessionFactory and SqlSessionTemplate is cancelled in
mybatis spring-1.3.2, so Property ‘SqlSessionFactory’ or ‘SqlSessionTemplate’ are required error will be reported.
you need to find a solution, so search the web for a solution, refer to this article, create a base class, and then let your dao inherit.
https://www.cnblogs.com/hawk0035/p/3337283.html?utm_source=tuicool
but my Mapper layer is using the annotated version of Mybatis, which is an interface and cannot inherit classes. So that’s not going to work.
since auto injection was eliminated in mybatis spring-1.3.2, I switched to a lower version of mybatis spring-1.1.1, but the fact remains the same, nothing has changed.
it is to find a way to don’t @ EnableAutoConfiguration (exclude = {DataSourceAutoConfiguration. Class}) automatic injection, so must the application. The properties to the application configuration file. The yml. The problem was finally solved.
Read More:
- Error: java.lang.IllegalArgumentExcept :Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required
- Springboot startup error: java.lang.IllegalArgumentException : Property ‘sqlSessionFactory’ or ‘sqlSessionTempla
- Validation failed for one or more entities. See ‘EntityValidationErrors’ property for more details
- C ා programming encountered an object reference is required for the non-static field, method, or property error
- Springboot project startup exception – required a single bean, but 2 were found
- Springboot integration redis reports non null key required (solved)
- Connection error:Cannot connect to redis-server. Details are available in connection log.
- “Failed to convert @ drawable / XX into a drawable exception details are logged in window”
- Error: sudo required (or change ownership, or define N_PREFIX)
- Eclipse Syntax error, annotations are only available if source level is 1.5 or greater
- Error creating bean with name ‘sqlsessionfactory’ defined in class path resource
- Springboot integrated with mybatis
- Syntax error, annotations are only available if source level is 1.5 or greater.
- Consult IDE log for more details (Help | Show Log),read failed, socket might closed or timeout,
- [resolved] error: Java: illegal character: ‘\ ufef’ or error: Java: class, interface or enum required
- Failed to instantiate org.mybatis.spring.SqlSessionTemplate Constructor threw exception
- Property or field ‘Title‘ cannot be found on object of type
- [Solved] error: Microsoft Visual C++ 14.0 or greater is required
- How to solve the problem of “version 11 or greater is required” in eclipse 2020
- “Syntax error, annotations are only available if source level is 1.5 or greater”