samedi 7 mars 2015

bean creator function not called when packaging into war in spring application

I have a spring REST application, which works fine if ran using mvn exec with embedded tomcat (beans get created fine, @Autowired works as expected, etc.).


If, however, I create a WAR using mvn package and deploy it into an existing tomcat, some bean creator functions do not get called.


For example, I have a bean creator function



@Bean
@Autowired
public ObjectMapper objectMapper(LocalizedMessages messages) {
// create and configure ObjectMapper with custom serializer
}


Which gets called when with an embedded tomcat, and does not get called when using war. I tried to add the containing class to the SpringApplicationBuilder's sources, but that did not have any effect.


Does anyone have a suggestion how I could get the war version to work properly?


Aucun commentaire:

Enregistrer un commentaire