Is it possible to combine spring boot @Value with javax.validation.constraints?


I would like to validate values in application.properties. I use @Value to inject and @NotBlank to validate the method parameter in a class annotated with @Configuration.

createSslContext( @Value("#{systemProperties['javax.net.ssl.trustStore']}") @NotBlank(message = "Truststore is needed") String path)

I have included the hibernate-validator and the hibernate-validator-annotation-processor properties. Using Spring 2.2.0.RELEASE.

It doesn't work. The value is injected, but not validated. What am I missing?


Add @Validated to your configuration class.

@Configuration @Validated public class MyConfig { @Bean MyClass createSslContext( @Value("#{systemProperties['javax.net.ssl.trustStore']}") @NotBlank(message = "Truststore is needed") final String path) { ... } }



  • I want to get all objects except text object as an image from PDF using iTextSharp
  • disable default user authentication in parse server
  • org.h2.jdbc.JdbcSQLException: The object is already closed
  • random font for website text?
  • Maven Resources Plugin: Build won't fail if directory doesn't exists
  • expand ipv6 address in shell script
  • How to process future stream to create an instance of class with list property
  • Efficient looping in objective-c
  • GIT shared over HTTPS git-receive-pack fails
  • Getting a photo of a place from Google Places Api
  • Remove Textmate Git Bundle
  • Keep play application running after putty terminal closed
  • JSON.stringify() - Escaping Issue
  • how java graphics repaint method actually works
  • 3 transitions, pausetime between transitions
  • Xamarin.Forms bind Height of Grid to Width of Button
  • Forward slash vs backward slash for file path in git bash
  • device tree overlay phandle
  • GLConsumer is already attached to a context for new SurfaceTexture
  • How to show functions callback and errors on UI with bloc pattern in Flutter?
  • Implementing type equation generator in OCaml
  • Google Compute instance receiving email
  • Problems with special characters in php soap client
  • Adding Dynamic Row and Data on Checkbox Click
  • Example of using Service Exists MSBuild task in Microsoft.Sdc.Tasks?
  • Circular Left Rotation Algorithm in C#
  • Adding horizontal slider to QTableWidget
  • Why do you need 2 Javascript files for cross-platform Cordova plugin?
  • Arraylist of strings into one comma separated string
  • Ember.js + JQuery-UI Tooltip - Tooltip does not reflect the model / controller changes
  • Why isn't stemDocument stemming?
  • read part of h5 dataset python