I am trying to read message.properties file from different location of a project if I keep my message.properties file in same application resource folder then I am able to read the message.properties file but when I change the location of my message.properties file then my application breaks I am reading my message.properties file using this method--spring.config.location=/home/sam/Desktop/message/message-configuration/message-service/resources/messages.properties
I specify this path at Environment variable that is present in intellij drop down option left of play button.I have attached the screen below for clarityenter image description here
Every time I move my message.property file to another location that is a different project I always get this errorNo message found under code 'spring.message.result' for locale 'en_IN'.
Code for message config
Message Service Interface
public interface MessageByLocaleService { public String getMessage(String id);}
Message Service Class
@Componentpublic class MessageByLocalServiceImpl implements MessageByLocaleService{ @Autowired private MessageSource messageSource; @Override public String getMessage(String id) { Locale locale = LocaleContextHolder.getLocale(); return messageSource.getMessage(id, null, locale); }}
Controller
@RestControllerpublic class MessageController { @Autowired MessageByLocaleService messageByLocaleService; @GetMapping("/getMessage") public String getMessage(){ return messageByLocaleService.getMessage("spring.message.result"); }}
messages.property File
spring.message.result="Welcome"