When integrating mybatis with springboot, an error of invalid bound statement (not found) is reported. After repeated changes and trial and error, it is found that mapper.xml cannot be scanned. The key lies in two aspects.
- if you put XML in the Java directory, you need to configure the path in the POM package
<resources> <resource> <directory>src/main/java</directory> <includes> <include>**/sqlmap/*.xml</include> </includes> <filtering>false</filtering> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.*</include> </includes> <filtering>true</filtering> </resource> </resources>
- add the statement of scan mapping file to mybatis configuration class
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); sessionFactory.setMapperLocations(resolver.getResources("classpath*:**/sqlmap/*.xml"));//扫描映射文件
- if the mapper.xml file is placed in the resources directory, maperlocations should be configured in application.yml
mybatis: mapper-locations: classpath:mapping/*.xml #Note: Be sure to correspond to the path where the mapper mapping xml file is located
- [Solved] SpringBoot Error: Property ‘mapperLocations‘ was not specified.
- Resources is configured in the build of Maven project to prevent the failure of resource export
- [Solved] Could not find resource COM / atguigu / Dao / studentdao.xm, the mapper file for storing SQL statements could not be found and an error occurred
- Cannot resolve reference to bean ‘sqlSessionFactory‘ while setting bean property ‘sqlSessionFactory‘
- [Maven] maven filtering OTS parsing error incorrect file size in WOFF head [Two Methods to Solve]
- Build a mybatis and it will appear session.selectOne Method error
- Springboot Project: How to Introduces Local Jar Package
- Java Running Error: Could not find or load main class
- Error querying database.Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource.
- [Solved] Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException
- [Solved] Error resolving template template might not exist or might not be accessible
- Springboot integration shiro error: UnsatisfiedDependencyException: Error creating bean with name ‘getShiroFilterFact
- Byte 1 of UTF-8 sequence of error creating document instance. And bytes is invalid
- keytool error: java.lang.Exception: Input not an X.509 certificate
- [Solved] org.thymeleaf.exceptions.TemplateInputException: Error resolving template
- How to Converte Java objects to jsonnode in Jackson (Four Methods)
- Error creating bean with name ‘servletEndpointRegistrar‘ defined in class path resource
- [Solved] Java.lang.IllegalStateException: Type handler was null on parameter mapping for property ‘__frch_it
- How to Solve Error: Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.
- Extracting JDBC tool class: JDBC utils