-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Cannot scan TypeHandler that pass Class<?> to constructor since 2.0.1 #370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @ondh, Could you provide small reproduce project via GitHub? |
I have tried the version 2.0.1 is the same error as 2.1.0. this is demo project with 2 branchs: |
@ondh Thanks for your quick feedback!! I will investigate cause of this issue. |
Hi @ondh , Sorry, this is a bug of mybatis-spring. For details, see mybatis/spring#394. This bug will fix at next regular maintenance release(mybatis-spring-boot 2.1.1 and mybatis-spring 2.0.3). WorkaroundI suggest workaround for fix this issue. You can apply a custom type handler to MyBatis by register it into the Spring DI container instead of package scan feature as follow: package fun.eien.mybatisbootdemo.config.mybatis;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MyBatisConfig {
@Bean
JSONArrayTypeHandler jsonArrayTypeHandler() {
return new JSONArrayTypeHandler(JSONArray.class);
}
@Bean
JSONObjectTypeHandler jsonObjectTypeHandler() {
return new JSONObjectTypeHandler(JSONObject.class);
}
} FYI, |
In your case(in your reproduce project), I think that not need pass the |
Thanks for your work. |
@ondh I've fixed this issue. Please try to use the 2.1.1-SNAPSHOT at you have a time. repositories {
// ...
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
// ...
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.1-SNAPSHOT'
// ...
} This issue will release at next maintenance version(about middle Oct 2019). Thanks again for your contribution!! |
my code is working fine with mybatis-spring-boot-starter:2.0.0
run application failed after upgrade to 2.1.0
I have tried some test:
working:
not working:
error log are follows:
The text was updated successfully, but these errors were encountered: