title: Syntax error, annotations are only available if source level is 5.0 - AspectJ in Maven
body: <p>I am trying to use the <code>aspectj-maven-plugin</code> in a maven project. At compile time, I get:</p>
  
  <pre><code>Syntax error, annotations are only available if source level is 5.0
  Syntax error, annotations are only available if source level is 5.0
  Syntax error, annotations are only available if source level is 5.0
  </code></pre>
  
  <p>Yet, I set the following in my pom.xml:</p>
  
  <pre><code>&lt;project.build.source&gt;1.6&lt;/project.build.source&gt;
  &lt;project.build.target&gt;1.6&lt;/project.build.target&gt;
  </code></pre>
  
  <p>I have some dependencies to:</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.aspectj&lt;/groupId&gt;
          &lt;artifactId&gt;aspectjrt&lt;/artifactId&gt;
          &lt;version&gt;1.6.11&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
          &lt;artifactId&gt;aspectj-maven-plugin&lt;/artifactId&gt;
          &lt;version&gt;1.4&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>How do I solve this issue? Thanks.</p>
  
  <p><strong>Solution</strong></p>
  
  <p>I added the following in my pom.xml and now it works:</p>
  
  <pre><code>        &lt;plugin&gt;
              &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
              &lt;artifactId&gt;aspectj-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;1.4&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;compile&lt;/goal&gt;
                          &lt;goal&gt;test-compile&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;source&gt;${project.build.source}&lt;/source&gt;  &lt;- Addition
                          &lt;target&gt;${project.build.target}&lt;/target&gt;  &lt;- Addition
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
             &lt;/executions&gt;
         &lt;/plugin&gt;
  </code></pre>