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

Add the spring implementation for the placeholder-type parameter of the JDBC Driver to read dynamic properties in the Spring Boot configuration file #31282

Closed
linghengqian opened this issue May 18, 2024 · 2 comments

Comments

@linghengqian
Copy link
Member

linghengqian commented May 18, 2024

Feature Request

For English only, other languages will not be accepted.

Please pay attention on issues you submitted, because we maybe need more details.
If no response anymore and we cannot make decision by current information, we will close it.

Please answer these questions before submitting your issue. Thanks!

Is your feature request related to a problem?

Describe the feature you would like.

  • Add athe spring implementation for the JDBC Driver's placeholder-type parameter to read the YAML properties of application.properties or application.yml into ShardingSphere's configuration file. This seems like a natural thing to happen.
  • We can actually only do unit testing on Spring Boot OSS 2.7, which has stopped being maintained, because I don't want to use Java API on Spring Boot OSS 3 on JDK8 through reflection.
  • Consider the following jdbcURL.
jdbc:shardingsphere:classpath:config.yaml?placeholder-type=spring
  • Assume that the following application.yml file exists in a typical Spring Boot project.
server:
  port: 8080

key:
    something:
        fixture-jdbc-url: jdbc:h2:mem:foo_ds_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL
        fixture-username: sa
  • Then for the intercepted fragment of the following YAML file config.yaml,
ds_1:
  dataSourceClassName: com.zaxxer.hikari.HikariDataSource
  driverClassName: $${key.something.fixture-driver-class-name::org.h2.Driver}
  jdbcUrl: $${key.something.fixture-jdbc-url::jdbc:h2:mem:foo_ds_do_not_use}
  username: $${key.something.fixture-username::}
  password: $${key.something.fixture-password::}
  • This YAML snippet will be parsed as,
ds_1:
  dataSourceClassName: com.zaxxer.hikari.HikariDataSource
  driverClassName: org.h2.Driver
  jdbcUrl: jdbc:h2:mem:foo_ds_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL
  username: sa
  password:
  • Considering that Spring's dependencies are so huge, this is definitely an optional module.
@linghengqian
Copy link
Member Author

  • I'm working on this issue.

@linghengqian
Copy link
Member Author

linghengqian commented Jun 8, 2024

  • This actually breaks the convention of Spring Boot. It is not reasonable to put the SPI implementation classes of ShardingSphere into the Spring container, because these classes are easily recreated by the context manager of ShardingSphere.

@linghengqian linghengqian closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2024
@linghengqian linghengqian removed their assignment Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant