Итак, я разработал какое-то приложение при весенней загрузке, я так запутался, как автоматически использовать PropertySourcesPlaceholderConfigurer setlocation, вот мой код
package com.org.tre.myth.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.io.FileSystemResource;
@Configuration
public class ExternalPropertyConfig {
@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
PropertySourcesPlaceholderConfigurer properties = new PropertySourcesPlaceholderConfigurer();
properties.setLocation(new FileSystemResource("/myth/app/data/weblogic_configuration/config/conf.properties")); //devpconfprop
properties.setLocation(new FileSystemResource("src/main/resources/conf.properties")); //localconfprop
properties.setIgnoreResourceNotFound(false);
return properties;
}
}
Когда я нахожусь на local Мне нужно деактивировать местоположение разработчика с помощью комментария
@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
PropertySourcesPlaceholderConfigurer properties = new PropertySourcesPlaceholderConfigurer();
//properties.setLocation(new FileSystemResource("/myth/app/data/weblogic_configuration/config/conf.properties")); //devpconfprop
properties.setLocation(new FileSystemResource("src/main/resources/conf.properties")); //localconfprop
properties.setIgnoreResourceNotFound(false);
return properties;
}
И прежде чем развернуть свое приложение в dev, мне нужно сделать противоположную вещь, комментируя мое локальное местоположение и активировать местоположение разработчика
@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
PropertySourcesPlaceholderConfigurer properties = new PropertySourcesPlaceholderConfigurer();
properties.setLocation(new FileSystemResource("/myth/app/data/weblogic_configuration/config/conf.properties")); //devpconfprop
//properties.setLocation(new FileSystemResource("src/main/resources/conf.properties")); //localconfprop
properties.setIgnoreResourceNotFound(false);
return properties;
}
есть ли способ, которым он может автоматически устанавливать местоположение, обнаруживая окружающую среду или что-то в этом роде? Пожалуйста, помогите мне, не стесняйтесь комментировать Спасибо, ребята.