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

More detailed Datasouce routing support #695

Open
yuhuangbin opened this issue Jan 2, 2025 · 1 comment · May be fixed by #697
Open

More detailed Datasouce routing support #695

yuhuangbin opened this issue Jan 2, 2025 · 1 comment · May be fixed by #697

Comments

@yuhuangbin
Copy link

present situation, We support multi data source routing through @DS annotation.
eg:

spring:
  datasource:
    dynamic:
      enabled: true
      primary: ds1
      datasource:
        ds1:
          driver-class-name: com.mysql.cj.jdbc.Driver
          url: jdbc:mysql://${ip}:${port}/${database}?useUnicode=true&characterEncoding=UTF-8
          username: xxx
          password: xxx
        ds2:
          driver-class-name: com.mysql.cj.jdbc.Driver
          url: jdbc:mysql://${ip}:${port}/${database}?useUnicode=true&characterEncoding=UTF-8
          username: xxx
          password: xxx
@DS("ds2")
@Service
public class UserServiceImpl implements UserService {
}

However, this method belongs to hard coding and cannot achieve dynamic configuration to specify data source routing switching. In some case, different data sources need to be specified for different methods under the same class. Refer: DynamicDatasourceNamedInterceptor, However, it has not been activated.
If it's worth it, I will fix it. Thanks

@gxmgxm
Copy link

gxmgxm commented Jan 2, 2025 via email

@yuhuangbin yuhuangbin linked a pull request Jan 3, 2025 that will close this issue
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 a pull request may close this issue.

2 participants