Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

193
Vistas
Loading additional spring profiles from java config

Is there any possibility to load aditional spring profiles from java config?

I know that I can use -Dspring.profile.active argument and also add profiles to spring.profiles.include in application.properties.

What I need is to be able to activate profiles from java config. I've created PropertyPlaceholderConfigurer, where I'm adding some custom property files, which also contains property spring.profiles.include, all properties are load and it works ok, but spring doesn't activate any profiles which are inclded using this property.

@Bean
public static PropertyPlaceholderConfigurer ppc() throws IOException {
    PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
    ppc.setLocations(new ClassPathResource("properties/" + property + ".properties"));
    ppc.setIgnoreUnresolvablePlaceholders(true);
    return ppc;
}
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The active spring profiles are defined in properties via the following configuration: spring.profiles.active:.

You should list in all the files that you import the profiles that they activate via the above configuration key.

EDIT

First, as per the official documentation the configuration spring.profiles.include is more suitable for unconditionally adding active profiles.

Second, I can assume that PropertyPlaceholderConfigurer is not suitable for what you want to achieve. The official documentation lists the ways you can Externalize Configuration. You can try to use @PropertySource:

@PropertySources({
        @PropertySource(value = "classpath:application.properties"),
        @PropertySource(value = "classpath:other.properties", ignoreResourceNotFound = true)
})
public class Application {
       ...
    }
}

Additionally, you can try to list the other properties files in property spring.config.location inside application.properties as described here.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda