mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 14:55:50 +00:00
Adds Bean to set the spring.messages.basenames
The spring.messages.basename property in application.properties does not support external paths like `file:/some/path/messages` so we set the property with `ReloadableResourceBundleMessageSource` where the `file:` notation is supported Signed-off-by: pmarkiewka <philipp.markiewka@cloudogu.com>
This commit is contained in:
parent
709fdc2773
commit
e76c389310
1 changed files with 18 additions and 0 deletions
|
@ -16,8 +16,12 @@
|
|||
|
||||
package org.springframework.samples.petclinic;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
|
||||
|
||||
/**
|
||||
* PetClinic Spring Boot Application.
|
||||
|
@ -28,8 +32,22 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@SpringBootApplication(proxyBeanMethods = false)
|
||||
public class PetClinicApplication {
|
||||
|
||||
@Value("${spring.messages.basename}")
|
||||
private String messagesBasename;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(PetClinicApplication.class, args);
|
||||
}
|
||||
|
||||
// The spring.messages.basename property in application.properties does not
|
||||
// support external paths like `file:/some/path/messages` so we set the
|
||||
// property with `ReloadableResourceBundleMessageSource` where the `file:`
|
||||
// notation is supported
|
||||
@Bean
|
||||
public MessageSource messageSource()
|
||||
{
|
||||
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
|
||||
messageSource.setBasenames( messagesBasename );
|
||||
return messageSource;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue