feat: messagesをホットリロードに対応

This commit is contained in:
usbharu 2024-08-26 17:47:41 +09:00
parent bd219b62e1
commit 533582534f
Signed by: usbharu
GPG Key ID: 8CB1087135660B8D
2 changed files with 30 additions and 1 deletions

View File

@ -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()
}
}

View File

@ -29,7 +29,8 @@ spring:
virtual: virtual:
enabled: true enabled: true
messages: messages:
basename: messages.hideout-web-messages basename: messages/hideout-web-messages
cache-duration: -1
thymeleaf: thymeleaf:
cache: false cache: false
server: server: