In my spring-boot application I have an existing dataSource, which I use for Hibernate and/or JdbcTemplate.
I am planning to use spring-session with spring-session-jdbc in the future.
Can the already existing and configured dataSource of the application be used?
If yes, how?
Or do I need to configure an additional dataSource for spring-session-jdbc?
The answer is:
Yes, it is possible, like the documentation of the newly released Spring Session 1.2.0 states:
http://docs.spring.io/spring-session/docs/current/reference/html5/guides/httpsession-jdbc-boot.html#httpsession-jdbc-boot-configuration
It also works without Spring Boot. In an old Spring-MVC project based on xml-config, which does not use Spring Boot, the configured dataSource is automatically used by Spring Session.
Related
I'm configuring HikariCP for Spring Boot application, the database is Postgresql.
The documentation says:
"We recommended using dataSourceClassName instead of jdbcUrl, but either is acceptable."
However, the next line says:
"Note: Spring Boot auto-configuration users, you need to use jdbcUrl-based configuration."
If we use jdbcUrl-based configuration and specify dataSourceClassName then jdbcUrl will be ignored, if we don't specify data source - HikariDataSource will be created. So they recommend using HikariDataSource for Spring Boot apps.
If we use dataSourceClassName - it will be created with given properties (in my case it is PGSimpleDataSource with its ancestor BaseDataSource).
Both these configurations work for me.
So, my questions are:
What is the difference between HikariDataSource and PGSimpleDataSource (or any other recommended)?
Why it is recommended to use jdbcUrl-based configuration (and thus HikariDataSource) in Spring Boot?
HikariCP is a connection pool, and a very good one. We've been using it in several projects in production and it's fast and just works.
If you want to use HikariCP you use HikariDataSource. Spring Boot has started to use it as a default and recommends it (for the same reasons: it's fast and solid).
If you just use the default configuration with spring.datasource.url, it will use HikariCP and should work out-of-the-box.
However, when you manually configure your datasource(s), there is a small issue with Spring Boot 2 and HikariCP. HikariCP expects jdbcUrl or dataSourceClassName, but the Spring Boot configuration property uses url.
See the documentation or this question for that.
Currently experimenting with reactive programming using Spring WebFlux.
I need to reset some values(create new instance of one class) every session.
It is not possible to inject a #RequestScope or #SessionScope bean as it will end up with IllegalStateExcepion error.
Is it possible to achieve session scope behavior in Spring Webflux? Any tips what can I use to achieve that?
Spring Session
In order to use sessions in Spring Webflux, you can use Spring Session, more specifically you can use the integration with Spring Webflux's WebSession
Some tutorial can be found here: https://www.baeldung.com/spring-session-reactive
I have resolved this by using hazelcast session replication.
I have an application created in Spring Boot https://github.com/JonkiPro/REST-Web-Services. I need to replace Hibernate provider with EclipseLink.The problem is that practically the entire configuration is found only in the application. properties https://github.com/JonkiPro/REST-Web-Services/blob/master/web/src/main/resources/application.yml file and I don't know what to change to EclipseLink.
There is an example project from Spring on how to use Spring Boot with EclipseLink. Please refer:
https://github.com/spring-projects/spring-data-examples/tree/master/jpa/eclipselink
I am using spring boot in my application, i want to know how to use Spring boot, iBatis and MySQL. While i am trying to find the reference for Spring boot with iBatis projects its automatically redirect to myBatis. I need a example project or site for referring this. I have example for mybatis but i want ibatis with spring boot.
I think, you shouldn't think how you may connect them. Just read docs about iBatis(MyBatis). But the following link special for you http://www.mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/
I have a spring-jpa-mvc-rest-hibernate web application that I use Java Config almost 99% on the whole app.
How can I configure Session per Request on pure Java Config? Preferable not using hibernate specific code, if that is possible.
I'm using Spring 4.2.2.RELEASE, Spring Data 1.11.0.RELEASE, Spring JPA 1.9.0.RELEASE, Spring WebMVC 4.2.2.RELEASE and Hibernate 5.0.2.Final.
Thanks a lot.