I'm planning to integrate Spring Session Redis + Spring Security in WebFlux Project.
And I am looking for some official documentation and references\Sample.But The Document only have Servlet Container Initialization.
I`m not quite sure the Spring Session REST support WebFlux Reactor applications.
In my limited experience with Spring,Thanks in advance.
Spring Session and Spring Security:
https://docs.spring.io/spring-session/docs/2.5.3/reference/html5/guides/java-security.html#servlet-container-initialization
Spring Session - REST:
https://docs.spring.io/spring-session/docs/2.4.6/reference/html5/guides/java-rest.html#servlet-container-initialization
Spring Session provides transparent integration with Spring WebFlux’s WebSession.
This is documented under "WebSession Integration" in the Spring Session reference docs.
You can see an example provided by the Spring Session team here.
If you are using Spring Boot and a single Spring Session module is present on the classpath, Spring Boot uses that store implementation automatically. There is no need for further configuration. You can find additional information in the Spring Boot reference docs.
If you are not using Spring Boot, you can use the annotation #EnableRedisWebSession to enable WebSession with Redis.
Related
I'm migrating a project from Spring 5.x to Spring 6 that previously used the KeycloakWebSecurityConfigurerAdapter which is now no longer supported. I've searched the internet and found that I need to migrate to Spring Security's OAuth2 solutions instead of using the adapter. I've also found a different post that tackles this question in the context of Spring Boot.
I don't have Spring Boot though, only Spring. I haven't found anything regarding the migration from the adapter to Spring Security without Spring Boot. How do I do it?
Just as when you don't use any other spring-boot module: you write by yourself what is auto-configured by spring-boot.
Refer to spring-boot documentation to figure out what beans are auto-configured in the case of the accepted answer to the question you linked (or to spring-security documentation to setup a resource-server with JWT decoder and custom authentication converter for roles mapping).
I have a set of RestControllers in a spring reactive web project and I want to prefix all of the controllers with "api" or "test-api" in different environments.
I have tried to use server.servlet.context-path=/api and it's not working with spring reactive web (webflux) running on Netty server
The following property was added in spring boot 2.3 to achieve this with webflux
spring.webflux.base-path
Release Notes: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes#configurable-base-path-for-webflux-applications
Have you tried using a placeholders in #RequestMapping, like for example #RequestMapping("${foo.bar}") ?
Thank you
I'm using spring boot 2.1.1 version and use #EnableWebFlux but I got some errors.
Errors are
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.reactive.config.DelegatingWebFluxConfiguration': Initialization of bean failed; nested exception is java.lang.IllegalStateException: The Java/XML config for Spring MVC and Spring WebFlux cannot both be enabled, e.g. via #EnableWebMvc and #EnableWebFlux, in the same application
How can I fix this problem.
You can't have both Spring MVC and Spring WebFlux enabled in Spring SPR-16609
enabling MVC and WebFlux in the same application context which triggers a conflict
you can't have them in the same process currently.
It offers a workaround to use use reactive repositories:
However, you can use reactive repositories from your existing Spring MVC application, and return the reactive types (Flux or Mono), from Spring MVC controller methods.
Based on Spring Docs and SpringFramework Collaborator Juergen Hoeller, you can have both Spring MVC and Spring WebFlux present in the same app. In this way, you are using Spring MVC by default, while you can have reactively enabled endpoints at the same time. Keep in mind, it is essentially a servlet-based MVC app you are using.
If you also have #EnableWebFlux on top of that, you mean that you wish to strictly turn this into a reactive web application.
My suggestion is to turn off #EnableWebFlux and keep your application straightly MVC-based. You can still use some of the reactive features such as Mono<> and Flux<> by importing Webflux dependencies.
I was facing the same issue as using io.springfox with Spring-WebFlux.
I changed to use springdoc and solved the issue: https://springdoc.org/#migrating-from-springfox
For sample detail you can check in this: https://github.com/mnguyencntt/springboot-webflux-swagger
I am new to spring mvc and DI. I have came to know about the flow of the spring project and i know how the web projects in spring mvc is developed and worked on few projects too. All the annotation uses and xml configuration files in the spring mvc. But i am confused where the DI is used? and how the DI is implemented in spring with the help of IOC??
Can anyone please explain me the concept of DI and IOC and their implementation in spring mvc.
Thanks in advance!!!
DI and IOC happening through web.xml where you created the dispatcherservlet.
From Spring MVC docs :
The DispatcherServlet, provides a shared algorithm for request processing while actual work is performed by configurable, delegate components
The DispatcherServlet, as any Servlet, needs to be declared and mapped according to the Servlet specification using Java configuration or in web.xml. In turn the DispatcherServlet uses Spring configuration to discover the delegate components it needs for request mapping, view resolution, exception handling, and more.
internally it will register Spring mvc app and it will create an object and inject dependencies .
Is there a way to enable yaml configuration (instead of properties file) in normal spring web mvc application without using spring boot and have the #Value annotation supported.
I searched a lot, everywhere it uses spring boot. I am not intrested to use spring boot, as its very heavy and have many dependancies configured for auto setup.
Any help would be appreciated......