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

269
Views
Cómo usar el resultado SpEL como clave @Value

En mi aplicación Springboot, quiero usar @Value para leer alguna configuración, pero esta configuración se usa en muchos otros métodos, por lo que quiero definir la clave de configuración como una constante. Este es el código:

 @Component public class InstanceConfig { private static final String CONFIGURE_KEY = "SUPPORT_MANAGER_PLANE_INSTANCES"; @Value("${SUPPORT_MANAGER_PLANE_INSTANCES}") private String supportManageInstances; @ApolloConfigChangeListener(value = ConfigConsts.NAMESPACE_APPLICATION) public void processConfigureChange(ConfigChangeEvent event) { log.info("configure changed do somthing"); ConfigChange configChange = event.getChange("SUPPORT_MANAGER_PLANE_INSTANCES"); } }

En esta variable de código "SUPPORT_MANAGER_PLANE_INSTANCES" utilizada por @Value y el método processConfigureChange , si es necesario modificar el valor de esta variable, necesito modificar todas las referencias de esta variable, por lo que quiero definir una variable constante CONFIGURE_KEY @Value y el método processConfigureChange usa esta variable.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Gracias por la ayuda de @hirarqi

 @Component public class InstanceConfig { private static final String CONFIGURE_KEY = "SUPPORT_MANAGER_PLANE_INSTANCES"; @Value("${" + CONFIGURE_KEY + "}") private String supportManageInstances; @ApolloConfigChangeListener(value = ConfigConsts.NAMESPACE_APPLICATION) public void processConfigureChange(ConfigChangeEvent event) { log.info("configure changed do somthing"); ConfigChange configChange = event.getChange(CONFIGURE_KEY); } }
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!