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

177
Views
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 answers
Answer question

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 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!