“Properti Spring DB” Kode Jawaban

Properti Spring DB

spring:
    profiles: local
    datasource:
        url: jdbc:postgresql://localhost:5432/postgres
        username: postgres
        password: root
code swifter

Properti Spring DB


@Configuration   
public class ConfigurationPropertySource {

private ConfigurableEnvironment env;

private final ConfigurationRepository configurationRepository;

    @Autowired
    public ConfigurationPropertySource(ConfigurationRepository configurationRepository) {
        this.configurationRepository = configurationRepository;
    }

    @Autowired
    public void setConfigurableEnvironment(ConfigurableEnvironment env) {

        this.env = env;
   }

   @PostConstruct
   public void init() {
    MutablePropertySources propertySources = env.getPropertySources();
       Map myMap = new HashMap();
       //from configurationRepository get values and fill mapp
       propertySources.addFirst(new MapPropertySource("MY_MAP", myMap));
   }

}

Successful Sloth

Jawaban yang mirip dengan “Properti Spring DB”

Pertanyaan yang mirip dengan “Properti Spring DB”

Lebih banyak jawaban terkait untuk “Properti Spring DB” di Java

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya