Within a Spring Component I have a @PostConstruct statement. Similar to below: During Unit tests I would not like to have the @PostConstruct function called, is there a way to telling Spring not to do post processing? Or is there a better Annotation for calling a initiation method on a class durning non-testing ? Answer Since you are not testing
Tag: spring
Making Spring 3 MVC controller method Transactional
I am using Spring 3.1 and have my DAO and service layer(transactional) written. However in a special case to avoid a lazy init exception I have to make a spring mvc request handler method @transactional. But It is failing to attach transaction to that method. Method name is ModelAndView home(HttpServletRequest request, HttpServletResponse response). http://forum.springsource.org/showthread.php?46814-Transaction-in-MVC-Controller From this link it seems it
Spring-data-mongodb connect to multiple databases in one Mongo instance
I am using the latest spring-data-mongodb (1.1.0.M2) and the latest Mongo Driver (2.9.0-RC1). I have a situation where I have multiple clients connecting to my application and I want to give each one their own “schema/database” in the same Mongo server. This is not a very difficult task to achieve if I was using the driver directly: See, easy. But
AspectJ pointcut expression match parameter annotations at any position
I’m trying to define a pointcut expression to match methods which contain a parameter annotated with a specific annotation, regardless of what position the parameter is in. In my case I’m looking for the @Constraint annotation. For example: Matching methods: So far I’ve tried the following expressions with no luck: Can someone point me to the right solution? is it
spring-data-mongo – optional query parameters?
I am using spring-data mongo with the JSON based query methods, and am unsure how to allow optional parameters in a search query. For instance – say I had the following function -but I didnt want to apply the name regex match, or not apply a date range restriction if NULL values were passed to the method. At the moment
Spring AOP Advice Called Twice
For some reason, my Spring AOP advices are being called twice. I checked: Spring AOP advice is called twice but I am not using the Component annotation, and am declaring the aspect bean once and annotating it with @Aspect and that’s it. Somewhat belatedly I realized that one of my classes was not implementing an interface yet, which caused CGLIB2
How to use for checking multiple Roles?
I want to display some content conditionally based on Roles using Spring Security JSP taglibs. But in Spring Security 3.1.x is checking for only one role. I can use but ifAllGranted is deprecated. Any help? Answer There is a special security expression in spring security: hasAnyRole(list of roles) – true if the user has been granted any of the roles
Include field name inside error message using Hibernate Validator
I’m using Hibernate Validator 4.2.0.Final and I’m looking for the simplest way to include class field name in my error message. What I found is the following thread Using a custom ResourceBundle with Hibernate Validator. According to this I should create my custom annotation for each constraint annotation adding one property to each one. Is there a cleaner way to
Error creating bean with name ‘org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter’
I am trying out a simple spring web service application. I have configured the application correctly but when i try access the wsdl file i get the following error: Here are my configuration files: ws-config.xml web.xml app-config.xml downloadMessageRequest.xsd Edit pom.xml Answer Do you have spring-expression in your Maven dependencies ? If you are not using Maven, check your WEB-INF/lib folder.
Calling @Transactional methods from another thread (Runnable)
Is there any simple solution to save data into database using JPA in a new thread? My Spring based web application allows user to manage scheduled tasks. On runtime he can create and start new instances of predefined tasks. I am using spring’s TaskScheduler and everything works well. But I need to save boolean result of every fired task into