Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5054

Picking messages.properties file from a different location using spring-config-location parameter

$
0
0

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"

Viewing all articles
Browse latest Browse all 5054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>