Skip to content
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

feat: 修改GlobalConfig的生成方法,由于目前无法在代码层面修改已加载后的GlobalConfig,所以做出这个修改 #6693

Closed
wants to merge 1 commit into from

Conversation

kirning
Copy link

@kirning kirning commented Feb 8, 2025

这样就可以在ConfigurationCustomizer上去修改GlobalConfig,同时不会影响已加载的配置。
比如用到了mysql和oracle两种数据库,但是根据当前是有的数据库使用不同的字段包装符合,有一个 columnForamt的配置可以做到,但是由于这个配置在 global-config 中的 db-config 配置中,所以无法在代码中动态的根据当前的数据源进行修改。目前只能通过重新实例化 SqlSessionFacotry 的办法解决,但这样一来就会导致配置文件中的默认配置全部失效。
SqlSessionFactoryBeanCustomizer 虽然可以在原来已加载配置的基础上修改配置,但是由于设置 globalConfig 的方法在调用这个方法的后面,所以无法生效
image

通过修改GlobalConfigUtils中的defaults方法可以让global-config对象全局唯一,这样在 SqlSessionFactoryBeanCustomizer 的修改的配置不会被后面的代码覆盖

…可以在ConfigurationCustomizer上去修改GlobalConfig,同时不会影响已加载的配置
@miemieYaho
Copy link
Contributor

你需要的是这个
image

@miemieYaho miemieYaho closed this Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants