Finally found how do do that !
First step : Define a CustomMessageSourceConfiguration class in the main webapp :
package fr.lepuyenvelay.cartocontrib.web;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
@Configuration
public class CustomMessageSourceConfiguration {
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasename("classpath:messages/messages");
messageSource.setDefaultEncoding("UTF-8");
return messageSource;
}
@Bean
public LocalValidatorFactoryBean getValidator() {
LocalValidatorFactoryBean bean = new LocalValidatorFactoryBean();
bean.setValidationMessageSource(messageSource());
return bean;
}
}
So it will load messages.properties in src/main/resources/messages folder.
Like explained here : https://www.baeldung.com/spring-custom-validation-message-source
Second step : Use @PostConstruct in module's config to add custom messages.properties
package fr.lepuyenvelay.cartocontrib.datastore;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import fr.lepuyenvelay.cartocontrib.service.datastore.DataStoreType;
import fr.lepuyenvelay.cartocontrib.service.datastore.DataStoreTypeManager;
@Configuration
public class CartocontribDatastorePostgisConfig {
final static Logger LOG = LoggerFactory.getLogger(CartocontribDatastorePostgisConfig.class);
@Autowired
DataStoreTypeManager dstManager;
@Autowired
ReloadableResourceBundleMessageSource messageSource;
@PostConstruct
private void init() {
dstManager.addSupportedDataStoreType(new DataStoreType("postgis"));
messageSource.addBasenames("classpath:messages/datastore-postgis-messages");
LOG.warn("DataStore Postgis chargé !!!");
}
}
By using messageSource.addBasenames we load the datastore-postgis-messages.properties stored in the module's src/main/resources/messages folder.