Closed linghengqian closed 1 year ago
Call @huayanYu to help review.
DynamicRoutingDataSource
has design flaws. This class attempts to inject a List<DynamicDataSourceProvider>
Spring Bean into a non-container environment, which causes the Spring Framework to deliberately take over this class and set a NoArgConstructor for this class with an unaligned parameter list.
As a fix, I added a AllArgsConstructor for DynamicRoutingDataSource
to avoid https://github.com/baomidou/dynamic-datasource/actions/runs/6080472779/job/16494489274?pr=560 display, injected List<DynamicDataSourceProvider>
is null.
Similarly, Alibaba Druid's Spring Boot Starter has a similar problem with Spring Bean introspection failures, resulting in the Spring Framework's improper initialization of beans.
I'll discuss how to manage GraalVM Reachability Metadata and convert Standard Metadata to Conditional Metadata in a new issue. Now the downstream still needs to add some of the contents of the JSON file itself. But the core problem has been solved, because nativeTest has already run through.
From this point of view, apart from the fact that SPEL cannot be used, we can claim that dynamic-datasource
should not conflict with GraalVM Native Image.
What kind of change does this PR introduce? (check at least one)
The description of the PR:
Other information:
DynamicRoutingDataSource
has design flaws. This class attempts to inject aList<DynamicDataSourceProvider>
Spring Bean into a non-container environment, which causes the Spring Framework to deliberately take over this class and set a NoArgConstructor for this class with an unaligned parameter list.As a fix, I added a AllArgsConstructor for
DynamicRoutingDataSource
to avoid https://github.com/baomidou/dynamic-datasource/actions/runs/6080472779/job/16494489274?pr=560 display, injectedList<DynamicDataSourceProvider>
is null.Similarly, Alibaba Druid's Spring Boot Starter has a similar problem with Spring Bean introspection failures, resulting in the Spring Framework's improper initialization of beans.