mypropertis.version=dev
in the empty space. Here we use mypropertis
as prefix, you can use whatever you want.
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; import lombok.Getter; import lombok.Setter; @Getter @Setter @ConfigurationProperties("mypropertis") @Component public class MyProperties { private String version= ""; }
Note that we have use lombok for the getter and setter.
@Autowired private MyProperties myProperties;
in our controllers / services
myProperties.getVersion()
The value woule be “dev” in this case.