diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/MessageSourceConfig.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/MessageSourceConfig.kt new file mode 100644 index 00000000..846d89ca --- /dev/null +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/MessageSourceConfig.kt @@ -0,0 +1,28 @@ +package dev.usbharu.hideout.core.config + +import org.springframework.boot.autoconfigure.context.MessageSourceProperties +import org.springframework.boot.context.properties.ConfigurationProperties +import org.springframework.context.MessageSource +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Profile +import org.springframework.context.support.ReloadableResourceBundleMessageSource + +@Configuration +@Profile("dev") +class MessageSourceConfig { + @Bean + fun messageSource(messageSourceProperties: MessageSourceProperties): MessageSource { + val reloadableResourceBundleMessageSource = ReloadableResourceBundleMessageSource() + reloadableResourceBundleMessageSource.setBasename("classpath:" + messageSourceProperties.basename) + reloadableResourceBundleMessageSource.setCacheSeconds(0) + return reloadableResourceBundleMessageSource + } + + @Bean + @Profile("dev") + @ConfigurationProperties(prefix = "spring.messages") + fun messageSourceProperties(): MessageSourceProperties { + return MessageSourceProperties() + } +} \ No newline at end of file diff --git a/hideout-core/src/main/resources/application-dev.yml b/hideout-core/src/main/resources/application-dev.yml index a6d4118b..2c19a35e 100644 --- a/hideout-core/src/main/resources/application-dev.yml +++ b/hideout-core/src/main/resources/application-dev.yml @@ -29,7 +29,8 @@ spring: virtual: enabled: true messages: - basename: messages.hideout-web-messages + basename: messages/hideout-web-messages + cache-duration: -1 thymeleaf: cache: false server: