Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring MVC @Controller and profiles

I have a spring mvc controller and I want to enable it only in some profiles (for example development and test).

I know I can use the profile attribute of the beans element in xml configuration to limit the scope of my beans, but I'm using convenient annotations for the controllers now.

Can I bind the annotated controller to given profile somehow?

Or do I have to use the "old way" (of implementing and declaring controller) without annotations and use the beans element in xml configuration?

Will the annotated controllers mix well with the "old ones"?

EDIT: another way, which comes to my mind, is to check the profile in runtime from autowired Environment instance, but this denies the inversion of control

like image 278
Kojotak Avatar asked Jun 12 '13 13:06

Kojotak


1 Answers

Is this what you mean ?

@Controller
@Profile("test")
public class CacheController {
}

javadoc

like image 190
MikePatel Avatar answered Oct 16 '22 15:10

MikePatel