Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am trying to set variiable throw SpEL in spring boot application:

@Value("${data.jndi-name:#{null}}")
private String jndiDataSource;

data.jndi-name should comes from application-{profile}.properties. But field jndiDataSource always null even if data.jndi-name exists.

Code with @Value("${data.jndi-name}") work fine but jndiDataSource contains empty string.

My question is how to set null to variable if property does not exists using SpEL.

upd: values comes from profile specific property file

This work well only when data comes from main application.properties. When data comes from profile profile specific property it's not work – theSemenov Aug 22, 2018 at 5:02

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.