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

Use Hikari rather than Commons DBCP in DataSource configuration examples #42971

Closed

Conversation

rajadilipkolli
Copy link
Contributor

From spring boot 2.x, the default DataSource library that comes with starter is Hikari, documentation is using commons-dbcp. To avoid confusion updating documentation to use HikariDataSource

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 1, 2024
@wilkinsona wilkinsona changed the title feat : change reference from commons-dbcp to HikariDataSource Using Hikari rather than Commons DBCP in DataSource configuration examples Nov 1, 2024
@philwebb philwebb added type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 1, 2024
@philwebb philwebb added this to the 3.2.x milestone Nov 1, 2024
@philwebb
Copy link
Member

philwebb commented Nov 1, 2024

Thanks!

@snicoll
Copy link
Member

snicoll commented Nov 1, 2024

@rajadilipkolli thanks for the PR but I am wondering what you see as confusing? This documentation you've updated is about configuring two datasources. These are manual configurations, and as such, don't really care about what the default in auto-configuration would be.

The documented examples also use two different datasources to show that's something possible if needed. I don't really see an interest at moving everything to Hikari.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Nov 1, 2024
@wilkinsona wilkinsona changed the title Using Hikari rather than Commons DBCP in DataSource configuration examples Use Hikari rather than Commons DBCP in DataSource configuration examples Nov 1, 2024
@rajadilipkolli
Copy link
Contributor Author

Hi @snicoll , when I copied the examples from documentation. It didn't work as import is not there then I realized that from starter only Hikari is there.

so, either we should change the example or update the documentation that we can use any choice of data source.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 2, 2024
@snicoll
Copy link
Member

snicoll commented Nov 2, 2024

. It didn't work as import is not there then I realized that from starter only Hikari is there.

Yes. This is an advanced configuration example of configuring multiple datasources. I don't believe that the starter changed from common dbcp to Hikari is the problem here.

update the documentation that we can use any choice of data source.

I don't understand what that means. The example already tries to show that you can use any choice of data source since it's doing exactly that.

You can't just copy/paste an example from the ref doc in "any" app and expect it to work. We could document that you need to add the relevant driver jar for the example to work but I personally am not sure that we need to go into that level of detail for an advanced example like this.

Let's see what the rest of the team thinks.

@snicoll snicoll added the for: team-attention An issue we'd like other members of the team to review label Nov 2, 2024
@mhalbritter
Copy link
Contributor

mhalbritter commented Nov 4, 2024

I agree with @snicoll. This in an advanced example which shows the power of this approach, so that you can even configure two totally independent datasources (in this case Hikari and Commons DBCP).

We could maybe add a HINT: that explains that this example configures two unrelated connection pools from different libraries?

@wilkinsona
Copy link
Member

I think we should accept the changes for the slice-test related examples as proposed. I don't think they need to use a custom type of DataSource to make their point.

As for the documentation on configuring an additional DataSource, arguably it is mixing two different things in the same section:

  1. How to configure an additional DataSource
  2. How to configure a DataSource of a non-default type

If you only care about 1, you don't need to see an example of 2. If you only care about 2, you don't need the complexity of it being an additional DataSource.

I think it might be clearer if the earlier "Configure a Custom DataSource" section covered using a custom type in some more detail. It already has an example using SomeDataSource as a bean but then shows using DataSourceBuilder with Hikari. If it showed how to use a custom type with DataSourceBuilder the later section on defining an additional datasource could use Hikari with a reference back to the "Configure a Custom DataSource" section that would now fully show how to use a pool other than Hikari.

@philwebb
Copy link
Member

philwebb commented Nov 4, 2024

I agree with @wilkinsona, I think consistently using Hikari would be best.

@@ -31,7 +31,7 @@ public class MyAdditionalDataSourceConfiguration {
@Bean(defaultCandidate = false)
@ConfigurationProperties("app.datasource")
public BasicDataSource secondDataSource() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return type needs to be changed to HikariDataSource as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @wilkinsona , I have updated PR to HikariDataSource but shouldn't it be DataSource ?

I feel DataSource is more accurate here.

@wilkinsona
Copy link
Member

wilkinsona commented Nov 6, 2024

Thanks for your efforts here, @rajadilipkolli. Unfortunately, things seem to be getting further away from what we want. For example, the latest commits make some changes to some of the tests that shouldn't be necessary. They also unnecessarily change a configuration property prefix which means that the property names no longer align with those in the documented example.

I'm afraid we don't have time to guide you through the necessary changes step-by-step. To receive that level of guidance, please keep an eye out for an issue that's labelled as ideal for contribution. I'm going to close this one now but thanks anyway for your efforts here and bringing the potential for improvement to our attention. I've opened #43054 to tackle it.

@wilkinsona wilkinsona closed this Nov 6, 2024
@wilkinsona wilkinsona removed for: team-attention An issue we'd like other members of the team to review status: feedback-provided Feedback has been provided labels Nov 6, 2024
@wilkinsona wilkinsona added the status: superseded An issue that has been superseded by another label Nov 6, 2024
@wilkinsona wilkinsona removed this from the 3.2.x milestone Nov 6, 2024
@rajadilipkolli rajadilipkolli deleted the update-documentation branch November 8, 2024 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another type: documentation A documentation update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants