title: Spring AWS - required bean could not be found
body: <p>I am trying to start my Spring server but keep getting this error:</p>
  
  <pre><code>Description:
  
  Parameter 0 of constructor in com.rm.awsimageupload.filestore.FileStore required a bean of type 'com.amazonaws.services.s3.AmazonS3' that could not be found.
  
  
  Action:
  
  Consider defining a bean of type 'com.amazonaws.services.s3.AmazonS3' in your configuration.
  </code></pre>
  
  <p>I have tried:</p>
  
  <ol>
  <li>pasting in the keys as strings right into the <code>BasicAWSCredentials</code></li>
  <li>putting the keys into <code>application.properties</code> and then using <code>@Value</code> to access them. With this approach, I get this error:</li>
  </ol>
  
  <pre><code>Error creating bean with name 'amazonConfig': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'local.AWS_ACCESS_KEY_ID' in value "${local.AWS_ACCESS_KEY_ID}"
  </code></pre>
  
  <p><strong>application.properties</strong></p>
  
  <pre><code>AWS_ACCESS_KEY_ID=NOTAREALKEY
  AWS_SECRET_ACCESS_KEY=NOTAREALSECRET
  </code></pre>
  
  <p><strong>FileStore.java</strong></p>
  
  <pre><code>
  @Configuration
  public class AmazonConfig {
  
      @Value("${application.AWS_ACCESS_KEY_ID}")
      private String AWS_ACCESS_KEY_ID;
  
      @Value("${application.AWS_SECRET_ACCESS_KEY}")
      private String AWS_SECRET_ACCESS_KEY;
  
      public AmazonS3 S3() {
          AWSCredentials awsCredentials = new BasicAWSCredentials(
              AWS_ACCESS_KEY_ID, 
              AWS_SECRET_ACCESS_KEY
          );
  
          return AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(awsCredentials)).withRegion(Regions.SA_EAST_1).build();
      }
  }
  </code></pre>
  
  <p><strong>pom.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.2.7.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      &lt;groupId&gt;com.rm&lt;/groupId&gt;
      &lt;artifactId&gt;aws-image-upload&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;aws-image-upload&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
      &lt;properties&gt;
          &lt;java.version&gt;11&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;org.junit.vintage&lt;/groupId&gt;
                      &lt;artifactId&gt;junit-vintage-engine&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;
              &lt;artifactId&gt;aws-java-sdk&lt;/artifactId&gt;
              &lt;version&gt;1.11.787&lt;/version&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  
  </code></pre>
  
  <p>Not exactly sure what to do... I am following a <a href="https://www.youtube.com/watch?v=i-hoSg8iRG0" rel="nofollow noreferrer">tutorial</a> on how to do this and my config pretty much matches this instructor's. Any suggestions?</p>