Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the tk.mybatis exception of SpringBoot2.0 Integration

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "how to solve SpringBoot2.0 integration tk.mybatis anomalies". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The configuration of pom is as follows (standard simple version):

Org.springframework.boot spring-boot-starter-parent 2.1.4.RELEASE 1.8 UTF-8 UTF-8 1.1.5 1.2.3 tk.mybatis mapper-spring-boot-starter ${tk.mybatis.version} Com.github.pagehelper pagehelper-spring-boot-starter ${pagehelper.version}

The startup report exception is as follows:

Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range:-1

Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range:-1

At java.lang.AbstractStringBuilder.substring (AbstractStringBuilder.java:908)

At java.lang.StringBuilder.substring (StringBuilder.java:76)

At tk.mybatis.mapper.mapperhelper.SqlHelper.getAllColumns (SqlHelper.java:247)

At tk.mybatis.mapper.mapperhelper.SqlHelper.exampleSelectColumns (SqlHelper.java:534)

At tk.mybatis.mapper.provider.ExampleProvider.selectByExample (ExampleProvider.java:96)

At tk.mybatis.mapper.provider.ExampleProvider.selectByExampleAndRowBounds (ExampleProvider.java:111)

At sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethod)

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 tk.mybatis.mapper.mapperhelper.MapperTemplate.setSqlSource (MapperTemplate.java:246)

... 29 common frames omitted

It is said that the version is incompatible, and it is not possible to replace the MapperScan annotation with tk. After searching for it for a long time, it is because there are no attributes defined in the defined data entity class:

When mapper scans the xml, it will look for the corresponding entity class and find that there is no field (column), so it throws an exception.

Why does this happen to bloggers?

When I build the framework, I will design the Controller, Service and Dao layers according to the product. I only define the entity of the Dao layer, and the contents are filled by specific developers, so there is an awkward situation in which the shelf is set up but cannot run. The solution is that the entity entity class should not be empty. Casually, just give it an id:

This is the end of the content of "how to solve SpringBoot2.0 Integration tk.mybatis anomalies". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report