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

Adds javax.sql.DataSource to refreshables #395

Closed
wants to merge 1 commit into from

Conversation

kerwin612
Copy link

Perfecting the processing method of gh-318

@spencergibb
Copy link
Member

Why do you think javax.sql.DataSource needs to be added?

@spencergibb spencergibb changed the title Perfecting the processing method of gh-318 Adds javax.sql.DataSource to refreshables Aug 27, 2018
@kerwin612
Copy link
Author

Can you take a look at #318 (comment)

Most of the time, we use interfaces, not subclasses, so I think 'javax.sql.DataSource' should in the default.

@spencergibb
Copy link
Member

Please try with boot 2.0.4 and Finchley.SR1

@kerwin612
Copy link
Author

I tried it, the problem is still the same, you can look at the sample code provided in #318 (comment).

@spencergibb
Copy link
Member

I can't run that code as I don't have mysql. Care to update it so there are no external dependencies (ie H2 or similar)?

@kerwin612
Copy link
Author

I have switched the database from mysql to h2, and the problem still exists. Please take a look.

@spencergibb
Copy link
Member

Adding the Datasource interface does indeed fix the issue, but is still only limited to Hikari. I'd rather not add it if Hikari is not used. Flagging for team discussion.

@kerwin612
Copy link
Author

Yes, but Hikari is used by default
😂

@spencergibb
Copy link
Member

What we're going to try and do is inspect the implementation type of the bean, that way we don't have to add DataSource which isn't needed if it is not Hikari.

@spencergibb
Copy link
Member

After trying to implement this, we are going to add a documentation note, but you should either set spring.cloud.refresh.extra-refreshable=javax.sql.DataSource or, more appropriately, strongly type your DataSource bean

	@Primary
	@Bean(name = "dbDataSource")
	@ConfigurationProperties(prefix = "datasource.db")
	public HikariDataSource dbDataSource() {
		return DataSourceBuilder.create().type(HikariDataSource.class).build();
	}

spencergibb added a commit that referenced this pull request Oct 4, 2018
spencergibb added a commit that referenced this pull request Oct 5, 2018
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.

None yet

2 participants