Mvn安装每次都失败

时间:2015-08-04 09:31:27

标签: java maven

我刚刚完成了与AspectJ的网络项目的整合,并遇到了以下问题:

我有两个项目:api(包含方面),web-app,其中web-app取决于api。我正在使用Java 7并在api项目中声明以下插件:

<plugin>
   <artifactId>maven-compiler-plugin</artifactId>
      <configuration>
          <source>1.7</source>
          <target>1.7</target>
          <encoding>UTF-8</encoding>
      </configuration>
</plugin>
<plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>aspectj-maven-plugin</artifactId>
   <version>1.7</version>
   <configuration>
      <outxml>true</outxml>
      <XterminateAfterCompilation>true</XterminateAfterCompilation>
   </configuration>
   <executions>
       <execution>
           <id>compile</id>
           <goals>
                <goal>compile</goal>
           </goals>
       </execution>
    </executions>
</plugin>

网络应用程序项目包含以下内容:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>1.7</version>
    <configuration>
        <outxml>true</outxml>
        <XterminateAfterCompilation>true</XterminateAfterCompilation>
        <aspectLibraries>
            <aspectLibrary>
                <groupId>ua.com.winforce</groupId>
                <artifactId>casino_aspect</artifactId>
            </aspectLibrary>
        </aspectLibraries>
     </configuration>

     <executions>
         <execution>
             <goals>
                  <goal>compile</goal>
             </goals>
         </execution>
      </executions>
</plugin>

问题是当我在执行mvn instal后尝试运行mvn clean时,它失败并出现多个错误:

 Syntax error, annotations are only available 
 if source level is 1.5 or greater

但第二个mvn install效果很好。这是AspectJ插件的错误吗?

1 个答案:

答案 0 :(得分:3)

尝试将源代码级别添加到aspectj maven plugin

<configuration> <source>1.7</source> <target>1.7</target> <complianceLevel>1.7</complianceLevel> </configuration>