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

176
Vistas
Spring Boot not picking up properties

I have a Spring Boot application and I'm trying to pass a property from application.properties as a parameter annotation within Entity class like that:

@Entity
public class Entity{

    @Id
    @SequenceGenerator(name = "entity_id_seq", sequenceName = "entity_id_seq", initialValue = "${start-seq}")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "dish_id_seq")
    private int id;

And my application.properties have:

start-seq=100000

But it doesn't compile saying "incompatible types: java.lang.String cannot be converted to int" not recognizing expression. Also I tried to pass this property with @Value annotation to a variable like that:

@Value("${start-seq}")
private int startSeq;

But the variable is always 0. I do have following annotations before my config class, but it still doesn't work:

@Configuration
@EnableConfigurationProperties
@PropertySources({
        @PropertySource("classpath:application.properties")
})

Am I missing something?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

@SequenceGenerator is not an Spring annotation. Thus spring does not evaluate this during the processing of the entity creation.

You can not use spring expression language (SpEl) here.

If you want to configure these, you have to use JPA oder Hibernate configuration for this.

Eg. write or extend the current SequenceGenerator. See here for details:

https://thorben-janssen.com/custom-sequence-based-idgenerator/

over 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