Skip to content

Commit

Permalink
Add ServiceMessageSourceFactoryBean for Spring Application
Browse files Browse the repository at this point in the history
  • Loading branch information
mercyblitz committed Apr 22, 2024
1 parent f57cc00 commit 27035dc
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
package io.microsphere.i18n.spring.boot.autoconfigure;

import io.microsphere.i18n.spring.annotation.EnableI18n;
import io.microsphere.i18n.spring.beans.factory.ServiceMessageSourceFactoryBean;
import io.microsphere.i18n.spring.boot.condition.ConditionalOnI18nEnabled;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;

/**
* I18n Auto-Configuration
Expand All @@ -28,4 +32,11 @@
@ConditionalOnI18nEnabled
@EnableI18n
public class I18nAutoConfiguration {

@Bean
@ConditionalOnProperty(name = "spring.application.name")
public ServiceMessageSourceFactoryBean applicationServiceMessageSource(
@Value("${spring.application.name}") String applicationName) {
return new ServiceMessageSourceFactoryBean(applicationName);
}
}

0 comments on commit 27035dc

Please sign in to comment.