The default makes the app start without the property being set anywhere.
@Value("${app.page-size:20}")
private int pageSize;
@Value("${app.tags:a,b,c}")
private List<String> tags; // comma-separated binds to a List
@Value("#{systemEnvironment['HOME']}")
private String home; // SpEL
pageSize = 20 when app.page-size is absent
tags = [a, b, c]
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-08-11