I had a working spring boot application including unit tests. But when I added AmazonSimpleEmailService feature to project, Spring application works without a problem and sends emails, however unit tests running with mvn clean install
throws exception:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.aws.core.region.StaticRegionProvider]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: The region '' is not a valid region!
Caused by: java.lang.IllegalArgumentException: The region '' is not a valid region!
Note that I added aws-config.xml :
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aws-context="http://www.springframework.org/schema/cloud/aws/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/cloud/aws/context
http://www.springframework.org/schema/cloud/aws/context/spring-cloud-aws-context-1.0.xsd">
<aws-context:context-credentials>
<aws-context:simple-credentials access-key="${cloud.aws.credentials.accessKey:}" secret-key="${cloud.aws.credentials.secretKey:}"/>
</aws-context:context-credentials>
<aws-context:context-region region="${cloud.aws.region.static:}"/>
</beans>
And this configuration in application.yml file:
cloud:
aws:
stack:
auto: false
region:
static: us-west-2
auto: false
credentials:
accessKey: __SomeAccessKey__
secretKey: __SomeSecretKey__
Any ideas?