I have a one trouble (sorry for my English)
I read property from file by MessageSource
( org.springframework.context.MessageSource ):
public class SomeConstants {
@Autowired
private static MessageSource messageSource;
private static final Locale locale = LocaleContextHolder.getLocale();
public static final String NULL_MESSAGE = messageSource
.getMessage( "propertyKey", new Object[]{}, locale );
}
Property file:
propertyKey = "Some message"
And I'm trying to pass NULL_MESSAGE
, from SomeConstants
class, to @NotNull
annotation ( javax.validation.constraints.NotNull ) as message parameter:
@NotNull( message = NULL_MESSAGE )
And when try to compile this, get compilation error (I use Maven to build project):
[ERROR] NULL_MESSAGE value must be a constant expression
It is possible to set value by MessageSource
during compilation or I should solve it by another way?