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.
Related
I have been looking all over the internet on how to configure Spring MVC 3 with redis but all in vain. I want to connect to redis using Spring MVC 3.
I have worked with spring boot and spring-data-redis and everything is working fine. I can connect to redis and store sessions. But the project I am currently working on is legacy based. It uses spring 3 but I believe spring-data-redis is compatible with spring 4 and above. Are there any alternates to make connection between spring 3 and redis. Any tutorial would be helpful.
I expect to store session data like username in the redis using Spring MVC 3
Well, from the documentation of the oldiest available spring-data-redis release
it looks like the minimal 2.x version is indeed spring 4
However, Spring data redis 1.x should work with spring 3.x:
https://docs.spring.io/spring-data/redis/docs/1.4.0.M1/reference/htmlsingle/#why-spring-redis
Having said that I haven't tried it by myself and if you're only storing sessions in redis, maybe using spring data is an overkill.
After all you can create a Jedis plugin by yourself, expose it as a bean and call the commands directly via the jedis driver. Its also possible to go with reactive client...
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.
I'm working on porting over an application into Spring MVC using Java Configuration so I don't have to use a web.xml file anymore.
For the most part it is working, except for session replication. The app currently runs on Tomcat and we use the distributable tag in the web.xml for session replication.
Does anyone know a way to make this work using Java configuration?
You could use Hazelcast for that. Please, see How to configure Hazelcast for session caching using spring while limiting it to a set of nodes? for how to configure it.
I have a Spring based application that uses Spring core, Spring MVC and Spring Data (Mongo) on the server side, and designed as a typical 3-tier application.
I have a list of services, that are typical Spring services/beans that I wish you integrate with memcached to cache some of my service results.
Can someone guide me to the steps to integrate memcached with spring for such an application?
A sample/tutorial/blog that gives a step by step process would be just great.
Thanks.
If you use Spring 3.1 take a look at Spring Cache abstraction. It's the easiest way to integrate caching in Spring application. Unfortunately Spring doesn't support memcached out of the box, there's only support for ehcache.
As far as I know there isn't available any provider that can store data to memcached through Spring Cache. In few days next version 3.0.0 of Simple Spring Memcached is going to be released with such support. In mean time you may try one of the latest snapshot or use Simple Spring Memcached 2.0.0 directly without Spring Cache abstraction.
UPDATE: Simple Spring Memcached 3.0.0 with Spring Cache integration is already available.
It's very trivial to do. You can look at 3levelmemcache project as an example at github its Spring based abstraction.
I am new to spring annotation and i want to create a sample example which shows the use of #Cacheable annotation in spring 3.1 does any one have guidance to create this ?
Hope following link may be helpful to you... A sample application.
Also have a look on Spring's documentation for cache abstraction and spring source blog post.
There are lots of links to learn from
simple-spring-memcached
Cache Abstraction Spring 3.2
Spring Expression Language (SpEL) Spring 3.2
Cache abstraction in Spring 3/
I did a POC using spring cache, Simple Spring Memcached and Memcache. The svn link of working application code is here
Simple Spring Memcached – Spring Caching Abstraction and Memcached