Я расширил свое приложение JHipster и написал класс обслуживания со следующим кодом:
@Component
@Transactional
public class AmazonClient {
private AmazonS3 s3Client;
@Value("${amazonProperties.endpointUrl}")
private String endpointUrl;
@Value("${amazonProperties.bucketName}")
private String bucketName;
@Value("${amazonProperties.accessKey}")
private String accessKey;
@Value("${amazonProperties.secretKey}")
private String secretKey;
public AmazonClient() {
}
@PostConstruct
private void initializeAmazon() {
AWSCredentials credentials = new BasicAWSCredentials(this.accessKey, this.secretKey);
this.s3Client = new AmazonS3Client(credentials);
}
мой application-dev.yml включает в себя следующее:
amazonProperties:
endpointUrl: https://s3.eu-central-1.amazonaws.com
accessKey: XYZ
secretKey: XYZ
bucketName: XYZ
Когда я запускаюприложение с mvwn все работает.Когда я запускаю свои тесты, я получаю следующее исключение:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'amazonClient': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'amazonProperties.endpointUrl' in value "${amazonProperties.endpointUrl}"