title: Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder
body: <p>I have issue with reading the values from the application.properties file and get the following errors,</p>
  
  <pre><code>[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.7.RELEASE:run (default-cli) on project wedding-card: An exception occurred while running. null: InvocationTargetException: Error creating bean with name 'weddingCardConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'aws.s3.access.key' in value "${aws.s3.access.key}" -&gt; [Help 1]
  org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.7.RELEASE:run (default-cli) on project wedding-card: An exception occurred while running. null
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
  
  
  Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occurred while running. null
      at org.springframework.boot.maven.AbstractRunMojo$IsolatedThreadGroup.rethrowUncaughtException (AbstractRunMojo.java:512)
      at org.springframework.boot.maven.RunMojo.runWithMavenJvm (RunMojo.java:94)
      at org.springframework.boot.maven.AbstractRunMojo.run (AbstractRunMojo.java:244)
  
  
  Caused by: java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke (Method.java:498)
      at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:543)
      at java.lang.Thread.run (Thread.java:748)
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'weddingCardConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'aws.s3.access.key' in value "${aws.s3.access.key}"
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties (AutowiredAnnotationBeanPostProcessor.java:380)
  
  Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'aws.s3.access.key' in value "${aws.s3.access.key}"
  </code></pre>
  
  <p>The pom.xml file is provided:</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 http://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.1.7.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      &lt;groupId&gt;com.wedcard&lt;/groupId&gt;
      &lt;artifactId&gt;wedding-card&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;wedding-card&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
      &lt;properties&gt;
          &lt;java.version&gt;1.8&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-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&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-mail&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.liquibase&lt;/groupId&gt;
              &lt;artifactId&gt;liquibase-core&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
              &lt;artifactId&gt;lombok&lt;/artifactId&gt;
              &lt;version&gt;1.18.8&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;io.springfox&lt;/groupId&gt;
              &lt;artifactId&gt;springfox-swagger2&lt;/artifactId&gt;
              &lt;version&gt;2.9.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;io.springfox&lt;/groupId&gt;
              &lt;artifactId&gt;springfox-swagger-ui&lt;/artifactId&gt;
              &lt;version&gt;2.9.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.pdfbox&lt;/groupId&gt;
              &lt;artifactId&gt;pdfbox&lt;/artifactId&gt;
              &lt;version&gt;2.0.16&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.stripe&lt;/groupId&gt;
              &lt;artifactId&gt;stripe-java&lt;/artifactId&gt;
              &lt;version&gt;10.0.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&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;/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.163&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.github.jhonnymertz&lt;/groupId&gt;
              &lt;artifactId&gt;java-wkhtmltopdf-wrapper&lt;/artifactId&gt;
              &lt;version&gt;1.1.11-RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;commons-io&lt;/groupId&gt;
              &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
              &lt;version&gt;2.6&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;!--        &lt;resources&gt;--&gt;
  &lt;!--            &lt;resource&gt;--&gt;
  &lt;!--                &lt;directory&gt;resources&lt;/directory&gt;--&gt;
  &lt;!--                &lt;targetPath&gt;${project.build.outputDirectory}&lt;/targetPath&gt;--&gt;
  &lt;!--                &lt;includes&gt;--&gt;
  &lt;!--                    &lt;include&gt;application.properties&lt;/include&gt;--&gt;
  &lt;!--                &lt;/includes&gt;--&gt;
  &lt;!--            &lt;/resource&gt;--&gt;
  &lt;!--        &lt;/resources&gt;--&gt;
      &lt;/build&gt;
  
      &lt;repositories&gt;
          &lt;repository&gt;
              &lt;id&gt;spring.io&lt;/id&gt;
              &lt;url&gt;https://repo.spring.io/plugins-release/&lt;/url&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>The configuration source file is here:</p>
  
  <pre><code>@Configuration
  @EnableSwagger2
  @EnableScheduling
  //@PropertySource(value = "classpath:application.properties")
  public class WeddingCardConfiguration implements WebMvcConfigurer {
  //    @Value("${spring.mail.host}")
  //    private String smtpMailHost;
  //    @Value("${spring.mail.port}")
  //    private int smtpMailPort;
  //    @Value("${spring.mail.username}")
  //    private String mailUsername;
  //    @Value("${spring.mail.password}")
  //    private String mailPassword;
  
      @Value("${aws.s3.access.key}")
      private String awsS3AccessKey;
      @Value("${aws.s3.access.secret}")
      private String awsS3AccessSecret;
      @Value("${aws.s3.bucket.region.name}")
      private String awsBucketRegionName;
  
  
      @Bean
      public Docket api() {
          return new Docket(DocumentationType.SWAGGER_2)
                  .select()
                  .apis(RequestHandlerSelectors.any())
                  .paths(PathSelectors.any())
                  .build();
      }
  
      @Override
      public void addCorsMappings(CorsRegistry registry) {
          registry.addMapping("/**").allowedOrigins("*");
      }
  
  //    @Bean
  //    public JavaMailSender javaMailSender() {
  //        JavaMailSenderImpl sender = new JavaMailSenderImpl();
  //        Properties prop = new Properties();
  //        prop.put("mail.smtp.auth", "true");
  //        prop.put("mail.smtp.starttls.enable", "true"); //TLS
  //        sender.setJavaMailProperties(prop);
  //        sender.setHost(smtpMailHost);
  //        sender.setPort(smtpMailPort);
  //        sender.setUsername(mailUsername);
  //        sender.setPassword(mailPassword);
  //
  //        return sender;
  //    }
  
      @Bean
      public AmazonS3 awsS3Client() {
          AWSCredentials credentials = new BasicAWSCredentials(awsS3AccessKey, awsS3AccessSecret);
  
          return AmazonS3ClientBuilder
                  .standard()
                  .withCredentials(new AWSStaticCredentialsProvider(credentials))
                  .withRegion(awsBucketRegionName)
                  .build();
      }
  }
  </code></pre>
  
  <p>The project has standard file structure provided:</p>
  
  <p><a href="https://i.stack.imgur.com/cWh7s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cWh7s.png" alt="enter image description here"></a></p>
  
  <p>I have tried to provide the property source information to the configuration class but still get the same error:</p>
  
  <pre><code>@Configuration
  @EnableSwagger2
  @EnableScheduling
  @PropertySource(value = "classpath:application.properties")
  public class WeddingCardConfiguration implements WebMvcConfigurer {
  
  
  }
  </code></pre>
  
  <p>I have also tried to provide explicitly the resources info to the pom file:</p>
  
  <pre><code>     &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;resources&gt;
              &lt;resource&gt;
                  &lt;directory&gt;resources&lt;/directory&gt;
                  &lt;targetPath&gt;${project.build.outputDirectory}&lt;/targetPath&gt;
                  &lt;includes&gt;
                      &lt;include&gt;application.properties&lt;/include&gt;
                  &lt;/includes&gt;
              &lt;/resource&gt;
          &lt;/resources&gt;
      &lt;/build&gt;
  </code></pre>
  
  <p>I keep getting the same error. Whats the issue here and how to solve it?</p>
  
  <p>ps: The email config values are commented purposefully and the error is not related to that</p>