I want a Spring Boot property to have an impossible to guess random value by default (for security reasons), so I am trying to use a random UUID as the default value, using code like this:
@Service
public class UserServiceImpl implements UserService {
...
@Autowired
public UserServiceImpl(@NonNull final PasswordEncoder passwordEncoder,
@NonNull final UserRepository userRepository,
@NonNull @Value("${administrator.password:${random.uuid}}") final String administratorPassword) {
...
}
But my Spring Boot tests are complaining about the ${random.uuid}
thus:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServiceImpl' defined in file [.../UserServiceImpl.class]: Unexpected exception during bean creation; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'random.uuid' in value "administrator.password:${random.uuid}"
What do I have to do to get my application to use a random property value?
Aucun commentaire:
Enregistrer un commentaire