Я пытался собрать военное приложение из приложения на ухо. Все работало нормально, пока я не столкнулся с ошибкой при чтении файла свойств из i18n_en_US.properties
.
Этот файл свойств находится под src/main/resources
и находится в мой dispatcher-servlet.xml
, я упомянул загрузку ресурса как:
Свойство читается как:
DeliveryApplicationContext.getMessage(CommonConstants.INVALID_SEARCH_ERROR_MESSAGE_VALUE)
Ниже приведен файл DeliveryApplicationContext:
public class DeliveryApplicationContext implements ApplicationContextAware{
/**
* Document delivery application context.
*/
private static ApplicationContext deliveryApplicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
deliveryApplicationContext=applicationContext;
}
/**
*
* @param beanName
* @return Object.
* This method will return bean from application context for parameter beanName.
* If application context is itself not initialized this method will return null.
*/
public static Object getBean(String beanName){
if( deliveryApplicationContext != null ) {
return deliveryApplicationContext.getBean(beanName);
}
return null;
}
/**
*
* @param token
* @return String.
* This method will return token value configured in application resource properties file.
*/
public static String getMessage(String token){
Locale locale = LocaleContextHolder.getLocale();
if( deliveryApplicationContext != null ) {
return deliveryApplicationContext.getMessage(token,null,locale);
}
return null;
}
public static void setdeliveryApplicationContext(ApplicationContext applicationContext) {
deliveryApplicationContext=applicationContext;
}
}
I у меня есть invalid.search.error.message
код в i18n_en_US.properties
, но все равно он выдает ошибку. Я исследовал в Google и попробовал предложенный способ, но у меня ничего не получилось.
То же самое работало, когда приложение было построено как ухо, но не удалось, пока мне нужно изменить его как развертываемый войной проект в Tomcat
Пожалуйста, кто-нибудь подскажет, в чем дело.