How to setting PropertySourcesPlaceholderConfigurer Auto SetLocations for External Configuration in Java Spring Boot

ReinHart :

I'am confused how to set location for External Configuration,

based on https://docs.spring.io/spring-boot/docs/1.2.2.RELEASE/reference/html/boot-features-external-config.html i do some external configuration but fail, Here is my code

package com.org.tre.myth.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;

@Configuration
public class ExternalPropertyConfig {


@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
final PropertySourcesPlaceholderConfigurer properties = new PropertySourcesPlaceholderConfigurer();

Resource[] resources = new Resource[ ] {
        new ClassPathResource("/myth/app/data/weblogic_configuration/config/conf.properties"), // i want this config used when i deploy it in dev
        new FileSystemResource("src/main/resources/conf.properties") // i want this config used when in local test
};

properties.setLocations( resources );
properties.setIgnoreResourceNotFound(true);
properties.setIgnoreUnresolvablePlaceholders(false);
return properties;
 }
}

it's always running on FileSystemResource, when i deploy, it doesn't wanna to read automatically from ClassPathResource when on dev. My config actually have same content (dev&test), the different is just at the directory because my dev do some layering and i want the configuration automatically running without even made a profile for spring.

I'am sorry

UPDATE

Im using this

Resource[] resources = new Resource[ ] {
            new FileSystemResource("/myth/app/data/weblogic_configuration/config/conf.properties"),
            new FileSystemResource("src/main/resources/conf.properties")
    };
ReinHart :

Using this

Resource[] resources = new Resource[ ] {
            new FileSystemResource("/myth/app/data/weblogic_configuration/config/conf.properties"),
            new FileSystemResource("src/main/resources/conf.properties")
    };

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Spring Boot auto configuration order from external dependency

How to load an external configuration with Spring Boot?

Spring Boot how to create Auto configuration class

Spring Boot external configuration in Groovy

Spring boot on Tomcat with external configuration

Spring Boot auto configuration for datasource

Spring Boot auto configuration for datasource

How to do unit test for spring boot auto configuration

How to exclude auto-configuration from Spring Boot WebMvcTest

Spring Boot: Profiles ignored in PropertySourcesPlaceholderConfigurer loaded file

Spring Boot External Configuration when using Docker

Spring boot external configuration in standalone jetty

Spring boot external configuration of property file

Spring Boot external configuration on another server

External configuration for spring-boot application

spring-boot external configuration entire class

Spring Boot LDAP - pooled property for auto configuration

Spring boot auto configuration with dependency and without @ComponentScan

How to return file that is in external domain? (spring boot / java)

How can I send data in POST body without setting the auto generated primary key values in Spring Boot?

Spring Boot external configuration without ignoring the packaged configuration

Read the Garbage Collection (GC) configuration from external file in Java | Spring Boot

Java Configuration of Spring Boot ApplicationPidListener

Java configuration of SimpleUrlHandlerMapping (Spring boot)

How to parse complex YAML into Java object hierarchy (Spring Boot configuration)

How to bind a yml map to a Java map in spring-boot configuration?

Spring Boot Auto Configuration Failed Loading Spring Kafka Properties

Disabling Spring JMS Auto configuration in Spring Boot Application

Spring Boot 2.1 - @WebMvcTest without Spring Security Auto-Configuration