I have spring boot application (1.1.5.RELEASE) and enabling my profiles via the configuration protperty spring.profiles.active=MyProfile
The profile gets activated correctly which I can see by beans from that profile being created.
Then I have a @Controller
used as follows:
@Controller
@RequestMapping("/someUrl")
@Profile("MyProfile")
public class MyController {
...
}
This controller is not instantiated and URL used in the controller are not mapped. In the same package I have another controllers which are not limited by @Profile
and these get instsantiated and mapped as expected.
So is using @Profile
annotation on controller something which is not compatible with spring boot? Is there other approach I should be using?
Edit: It seems to be a bug after all as if I include -Dspring.profiles.active=MyProfile
as JVM property the controller gets instantiated :'(
Edit2: So here comes the interesting part:
If you define
spring.profiles.active
inapplication.properties
which is loaded by default from classpath thne it workswhen you rename the file to
test.properties
and include it via@PropertySource("classpath:test.properties")
it stops working. Will raise a bug against it.
Edit 3: As promised: https://github.com/spring-projects/spring-boot/issues/1417
Thanks!