-
Notifications
You must be signed in to change notification settings - Fork 1
Cannot bind configuration properties to MybatisProperties #13
Comments
I found difference with timing of bean creation. Running with native-imageMyBatis's components was created before create the
Running with executable jarMyBatis's components was created after create the
|
Do you know a cause for this behavior? I would be grateful if tell me a hint for resolving this issue when you have time. |
I am trying to get my head around all the details. Is this happening only in the native image or can you reproduce the problem with AOT on the JVM? |
@snicoll Thanks for reaction! This problem occurred only when run with native-image. |
@snicoll I've tried joshlong's sample, it has been occurred same issue. |
Sorry, tell me how to run with AOT on JVM? |
Once your jar is built, |
@snicoll this issue occurred running with AOT on JVM too. |
@snicoll |
Bean definition of BeanDefinitionRegistrar.of("cityMapper", MapperFactoryBean.class)
.instanceSupplier(() -> new MapperFactoryBean()).customize((bd) -> {
MutablePropertyValues propertyValues = bd.getPropertyValues();
propertyValues.addPropertyValue("mapperInterface", CityMapper.class);
propertyValues.addPropertyValue("addToConfig", true);
propertyValues.addPropertyValue("sqlSessionTemplate", new RuntimeBeanReference("sqlSessionTemplate"));
}).register(beanFactory); |
@kazuki43zoo could you please share a minimal sample that I can run to reproduce this? |
@snicoll You can reproduce this issue using How to build:
|
Thanks. I've reproduced the problem. The injection of the It shouldn't even do that for the |
So I've made some progress. It's unclear why the context behaves this way in AOT, and does not with a regular runtime but injecting the environment this way in a Fixing the above may not fix this issues as there might be another processor that does something similar. |
With the fix on the Spring Boot issue, I am getting the following:
I don't get those without AOT so we're at least making progress as the issue is clearly logged by the context now. This one is triggered by |
@snicoll Thanks for your work and feedback! I will try using latest Spring Boot snapshot version! |
No, thank you! You shed some light on a nasty problem. I am happy to share that I have some code that fixes the problem that I am now polishing so that it it is hopefully available in the next maintenance release. Thanks again. |
Unfortunately, I spoke too soon. I thought I had fixed the issue but I haven't. Still investigating. Edit: I think I found it, I'll try to submit a PR shortly. |
I believe that #32 is one way to fix this issue. Let me know what you think. |
Current status:
Sample |
This is the expected behavior and nothing we can do about it. |
Cannot bind configuration properties to
MybatisProperties
, if mapper was scanned (can bind, if mapper not scanned).I add configuration property of mybatis-spring-boot as follows:
e.g.)
mybatis.configuration.map-underscore-to-camel-case=true
The
MybatisPropertyies#getConfiguration()
returnnull
when running on native-image.reproduce project
How to reproduce
Build
Run with native-image(Actual Result)
Run with executable jar(Expected Result)
Workaround
Can use the programmatic based configuration as follows:
The text was updated successfully, but these errors were encountered: