I set up this binding with Guice
bindConstant().annotatedWith( SecurityCookie.class ).to("JSESSIONID");
I need to migrate to Spring.
What would be the equivalent code with Spring ?
Use FieldRetrievingFactoryBean.
Related
Is there any chance that CDI and spring dependency injection could co-exist. The problem started when I tried using JpaRepository interface.
I cannot remove beans.xml as it breaks a common jar implementation which uses CDI. I tried #Vetoed but it then fails to autowire my JpaRepository interface in a service class. Does it mean that #Vetoed prevents the bean from being managed by spring also?
I am looking for an idea so that i could use CDI to manage some beans and spring to manage the rest.
spring-boot-starter-webflux can not use org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver
so how can spring-boot-starter-webflux use resolveLocale?In other words, what is there in reactor that is similar to resolveLocale?
Spring WebFlux is configuring and using by default a org.springframework.web.server.i18n. LocaleContextResolver (with org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver and org.springframework.web.server.i18n.FixedLocaleContextResolver as implementations).
You can inject the java.util.Locale as a Controller argument (if you're using the annotation variant of Spring WebFlux), or inject and use the configured LocaleContextResolver bean and use it directly.
i'm looking to advice setters of entity classes using AspectJ on Spring Boot, but i found that only spring beans could be advised.
Is there any trick to advice setters of entity classes (for example), these entity classes could not be spring beans.
only spring beans could be advised
Well, it's true in case you are using Spring AOP and not(!!!) AspectJ.
If replacing Spring AOP with AspectJ is an option, you can weave what ever you like by using #Configurable
Here
You can find the documentation that says that you can put Spring annotations like #Transactional on your non beans instances.
What is the equivalent of Guice's #ImplementedBy annotation in Spring DI? (I googled it but with no results.)
There is not exist JIT default binding in Spring. You can set only one implementation to dependency or use naming qualifier #Named or #Qualifier annotation to specify implementation but this is static binding (not equivalent to #ImplementedBy Guice implementation).
I created a spring extension enabling the jit-binding. this library add #ImplementedBy annotation to Spring. See https://github.com/devacfr/spring-implementedby and give me feedback
You can use the annotation #Qualifier
http://static.springsource.org/spring-framework/docs/3.2.0.M2/api/org/springframework/beans/factory/annotation/Qualifier.html
In struts2 i almost did not use any xml configs and used much of annotations for MVC. I build a small application in that way using struts2. Now i want to develop same project using spring 3.2. Now i want to use annotation to create beans and request mapping (this i used). I want a clear example of using bean annotations and is it possible to set properties using annotations. I am getting confused because the documentation is too large, and many annotations. providing a simple list of annotations and their usage with simple example will be a great help.
Iam doing sample project on Spring 3.1.
I have used some annotations to create beans.Below are the annotations i have used.
#Component - Annotation used to create a bean given by Spring
#Resource,#Bean
JSR Annotations: #Controller,#Repository, #Service
If you are annotating your class with above annotations Spring Container will create beans for you.
Your properties will be set with help of #Autowired annotation.