-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
Spring boot - add autoconfiguration #64
Comments
Hello @tomaszglinski thanks for your interest in this project. I believe what you are asking for is already possible: Have you seen the note on the README re. the MariaDB4jSpringService, which you can very easily use in a Spring Boot application, as illustrated in the MariaDB4jApplication or the MariaDB4jSpringServiceTestSpringConfiguration? If you need an even tighter automated integration with an autoconfiguration, then you're more than welcome to propose something via a pull request to this open source project ... ;-) If there are replies, I'll close this issue in 1 month from today. |
Hi, true, I didn't found the examples before. Unfortunately it is still not working. In debug mode I see that, propertyPlaceholderConfigurer method is called during Spring context startup, but the mariaDB4jSpringService method not. Test run ends with
I suppose there is wrong order of initialization, mariaDb4j should start before entity manager starts its initialization (including connection pool init). Just to mention, my app uses also flyway for db schema initialization/update, that is done also just at the startup. No idea now how to fix that, must think over the weekend.... |
@tomaszglinski You may be able to force the correct order of initialization by making whatever you have that requires MariaDB4j have an Inject / AutoWired dependency on a DB instance, and writing a Provider thus making it explicit that you require it and that it thus must be started before? Beyond that, I'm afraid I can't offer you any further support with integration of MariaDB4j into your app; I'm sure you understand. Best of luck! |
@tomaszglinski to achieve the correct initialization order, use Spring's named beans and Although I did not checked if this exact code is running correctly, but it's stripped out from our "integration test suite" we use daily. |
Tkanks a lot for gist, will check it on monday!
1 kwi 2017 20:02 "zaenk" <notifications@github.com> napisał(a):
… @tomaszglinski <https://github.com/tomaszglinski> to achieve the correct
initialization order, use Spring's named beans and @dependsOn annotation.
The DataSource initialization have to wait until MariaDB is ready to
receive connections. *This gist shows a minimal example
<https://gist.github.com/zaenk/71e2e1ee5340fa19a4fcd3b67b003a59>*.
Although I did not checked if this exact code is running correctly, but
it's stripped out from our "integration test suite" we use daily.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/vorburger/MariaDB4j/issues/64#issuecomment-290936765>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AISmDxEsQWedUpqDXY4riI5s9NlKFkUkks5rrpFOgaJpZM4MvpDf>
.
|
@zaenk thank you for contributing this! FYI I've worked this into vorburger@562b1a7 so others can find your tip & gist more easily.. Do feel free to send Pull Requests to further clarify the README better, or even contribute a full running example! |
@vorburger I also have this problem of the order of initialization, I fixed it by this code: @Configuration
@Profile("test")
class TestDataSourceConfiguration {
@Bean
MariaDB4jSpringService mariaDB4jSpringService() {
new MariaDB4jSpringService()
}
@Bean
@DependsOn("mariaDB4jSpringService")
DataSource dataSource(DataSourceProperties dataSourceProperties) {
DataSourceBuilder.create()
.username(dataSourceProperties.username)
.password(dataSourceProperties.password)
.url(dataSourceProperties.url)
.driverClassName(dataSourceProperties.driverClassName)
.build() as DataSource
}
} But I hold that it is not a good code, cause I don't want to overwrite the implement of the bean I found that Spring can auto config |
@kbyyd24 I don't have plans to implement this, but I welcome Pull Requests from you / anyone. |
@vorburger I have tried to add the code in previous comment into the But it broken the module
You can see the commit in my fork of the repo. I don't know how to fix the error, maybe I need another project to implement auto-configure mariaDB4j. |
Actually, I am not really understand what is mariaDB4j-app doing. Could you explain some? |
@kbyyd24 See the README, "Note the use of the special mariaDB4j-app*.jar for this use-case, its a fat/shaded/über-JAR, based on a Spring Boot launcher." - it's more of an example. Perhaps what you are trying to do here should not go into mariaDB4j-core but a new mariaDB4j-springboot - I'm not sure, try. Unfortunately personally I cannot help you to debug your Spring Boot related problem - but I'm happy to code review any working PR. But any other MariaDB4j community users who have an interest in and want to jump on helping you with this are very vey welcome to comment here - that would be very cool. |
"Perhaps what you are trying to do here should not go into mariaDB4j-core but a new mariaDB4j-springboot" This is a good idea, and I implemented it in PR (https://github.com/vorburger/MariaDB4j/pull/153). By this way, I don't need to change module mariaDB4j-app. Thanks for your help. |
Closing this just to clean up, as we are near having this solved by #153 (reviewed earlier today). |
That's an old topic, but just asking as I wanted to use it... has anyone used it actually? Because it doesn't work... |
Hi there,
I am trying to somehow replace the H2 with Mariadb4j for tests in spring boot apps, but i'm having problems with that.
The H2 db startsup very nice out of the box if only available on classpath. It would be a great boost for popularity of this project, if it was prepared for spring boot. A lot of people are complaining about H2 incompatibility.
The text was updated successfully, but these errors were encountered: