Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
Carga de archivos de propiedades de Java por perfil

Quiero cargar archivos de propiedades en código Java. Pero uso el perfil para configurar -Dspring.profiles.active=local o dev... Cómo cargar archivos de propiedades por perfil Algo como esto:

 classpath:${spring.profiles.active}/test.properties

¿Cómo hacer eso en código Java? Hice lo siguiente, pero obtuve nulo.

 Properties prop = new Properties(); InputStream iStream = Helper.class.getClassLoader().getResourceAsStream("test.properties"); try { prop.load(iStream); } catch (IOException e) { LOG.error(e.getMessage(), e); } finally { try { iStream.close(); } catch (IOException e) { LOG.error(e.getMessage(), e); } }
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Este es un código de trabajo para nosotros:

 String activeProfile = System.getProperty("spring.profiles.active"); InputStream workSpacesFIS = this.getClass().getClassLoader() .getResourceAsStream(activeProfile + "/customers.txt"); if (workSpacesFIS != null) { ...
over 4 years ago · Santiago Trujillo Report

0

Carga de archivos de propiedades de Java por perfil

 public Properties getProp() throws IOException { final Properties prop = new Properties(); prop.load(TestService.class.getResourceAsStream("/application.properties")); String activeProfile = prop.getProperty("spring.profiles.active"); prop.load(TestService.class.getResourceAsStream("/application-"+activeProfile+".properties")); return prop; }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!