java - 为什么 Maven 构建无法解析 @Override 注解?

标签 java eclipse maven amazon-web-services

我正在尝试将我的 AWS SWF 工作流程转移到 Maven。我将 Maven 与 Eclipse 一起使用。我使用 Eclipse 启用了注释。但它显示注释错误。

PFB 我的 POM.xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<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">
  <modelVersion>4.0.0</modelVersion>

  <groupId>solution.heavywater</groupId>
  <artifactId>HW</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>AWS SDK for Java Sample</name>
  <url>http://aws.amazon.com/sdkforjava</url>
 <properties>
    <aws-version>1.9.13</aws-version>
    <powermock.version>1.6.1</powermock.version>
    <aspectjweaver.version>1.7.4</aspectjweaver.version>
    <slf4j.version>1.7.10</slf4j.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <javancss.source.base>../all-sources</javancss.source.base>
  </properties>
  <dependencies>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk</artifactId>
      <version>[1.7.2,2.0.0)</version>
    </dependency>
    <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>${aspectjweaver.version}</version>     
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-s3</artifactId>
            <version>${aws-version}</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-dynamodb</artifactId>
            <version>${aws-version}</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-sns</artifactId>
            <version>${aws-version}</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-sqs</artifactId>
            <version>${aws-version}</version>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.1</version>
        </dependency>
        <dependency>
          <groupId>commons-configuration</groupId>
          <artifactId>commons-configuration</artifactId>
          <version>1.6</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-swf-libraries</artifactId>
            <version>${aws-version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.10.8</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4</artifactId>
            <version>${powermock.version}</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito</artifactId>
            <version>${powermock.version}</version>
        </dependency>
    <dependency>
      <groupId>net.sourceforge.cobertura</groupId>
      <artifactId>cobertura</artifactId>
      <version>2.0.3</version>
       <exclusions>
        <exclusion>
            <artifactId>tools</artifactId>
            <groupId>com.sun</groupId>
        </exclusion>
        <exclusion>
            <artifactId>xalan</artifactId>
            <groupId>xalan</groupId>
        </exclusion>
        <exclusion>
            <artifactId>xercesImpl</artifactId>
            <groupId>xerces</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
        <groupId>xalan</groupId>
        <artifactId>xalan</artifactId>
        <version>2.7.2</version>
    </dependency>
    <dependency>
        <groupId>xerces</groupId>
        <artifactId>xercesImpl</artifactId>
        <version>2.11.0</version>        
    </dependency>
     <dependency>
        <groupId>org.zeroturnaround</groupId>
        <artifactId>zt-zip</artifactId>
        <version>1.8</version>        
    </dependency>
    <dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>itextpdf</artifactId>
    <version>5.5.5</version>
</dependency>

    <dependency>
        <groupId>commons-httpclient</groupId>
        <artifactId>commons-httpclient</artifactId>
        <version>3.1</version>
    </dependency>
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.2</version>
    </dependency>   
    <dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.4</version>
    </dependency>   
    <dependency>
    <groupId>org.json</groupId>
    <artifactId>json</artifactId>
    <version>20140107</version>
</dependency>
    <dependency>
    <groupId>org.im4java</groupId>
    <artifactId>im4java</artifactId>
    <version>1.4.0</version>
</dependency>


</dependencies>


 <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>sonar-maven-plugin</artifactId>
          <version>2.5</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>javancss-maven-plugin</artifactId>
          <version>2.1</version>
        </plugin>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>2.14</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>xml-maven-plugin</artifactId>
          <version>1.0</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.18.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.8</version>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.8</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>1.8</version>
        </plugin>
        <plugin>
          <groupId>com.jcabi</groupId>
          <artifactId>jcabi-dynamodb-maven-plugin</artifactId>
          <version>0.7.1</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <version>1.3.2</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>properties-maven-plugin</artifactId>
          <version>1.0-alpha-2</version>
        </plugin>
        <!--This plugin's configuration is used to store Eclipse m2e settings only. 
        It has no influence on the Maven build itself.-->
        <plugin>
            <groupId>org.eclipse.m2e</groupId>
            <artifactId>lifecycle-mapping</artifactId>
            <version>1.0.0</version>
            <configuration>
                <lifecycleMappingMetadata>
                    <pluginExecutions>
                        <pluginExecution>
                            <pluginExecutionFilter>
                                <groupId>
                                    org.apache.maven.plugins
                                </groupId>
                                <artifactId>
                                    maven-antrun-plugin
                                </artifactId>
                                <versionRange>[0,100]</versionRange>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </pluginExecutionFilter>
                            <action>
                                <ignore></ignore>
                            </action>
                        </pluginExecution>
                        <pluginExecution>
                            <pluginExecutionFilter>
                                <groupId>org.codehaus.mojo</groupId>
                                <artifactId>
                                    build-helper-maven-plugin
                                </artifactId>
                                <versionRange>[0,)</versionRange>
                                <goals>
                                    <goal>regex-property</goal>
                                </goals>
                            </pluginExecutionFilter>
                            <action>
                                <ignore></ignore>
                            </action>
                        </pluginExecution>
                        <pluginExecution>
                            <pluginExecutionFilter>
                                <groupId>org.codehaus.mojo</groupId>
                                <artifactId>
                                    properties-maven-plugin
                                </artifactId>
                                <versionRange>[0.0,100]</versionRange>

                                <goals>
                                    <goal>read-project-properties</goal>
                                </goals>
                            </pluginExecutionFilter>
                            <action>
                                <ignore></ignore>
                            </action>
                        </pluginExecution>
                    </pluginExecutions>
                </lifecycleMappingMetadata>
            </configuration>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>regex-property</id>
            <phase>initialize</phase> 
            <goals>
              <goal>regex-property</goal>
            </goals>
            <configuration>
              <name>top.root.dir</name>
              <value>${session.executionRootDirectory}</value>
              <regex>WONT_FIND_ME_HACK</regex>
              <replacement>WONT_FIND_ME_HACK</replacement>
              <failIfNoMatch>false</failIfNoMatch>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <executions>
          <execution>
            <phase>compile</phase> 
            <goals>
              <goal>read-project-properties</goal>
            </goals>
            <configuration>
              <files>
                <file>${session.executionRootDirectory}/target/dynamo.properties</file>
                <file>${session.executionRootDirectory}/checkstyle-max-violations.properties</file>
              </files>
              <quiet>true</quiet>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>javancss-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>javancss</id>
            <phase>verify</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>

        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <configuration combine.self="override">
          <configLocation>src/test/resources/checkstyle-rules.xml</configLocation>
          <suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
        </configuration>
        <executions>
          <execution>
            <id>checkstyle</id>
            <phase>verify</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>xml-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>transform-results</id>
            <phase>verify</phase>
            <goals>
              <goal>transform</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <transformationSets>
            <transformationSet>
              <dir>target</dir>
              <includes>
                <include>checkstyle-result.xml</include>
              </includes>
              <stylesheet>${session.executionRootDirectory}/src/test/resources/checkstyle-results.xsl</stylesheet>
              <outputDir>target/checkstyle-reports</outputDir>
              <fileMappers>
                <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                  <targetExtension>.html</targetExtension>
                </fileMapper>
              </fileMappers>
            </transformationSet>
          </transformationSets>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <systemPropertyVariables>
            <dynamodb.port>${dynamodblocal.port}</dynamodb.port>
          </systemPropertyVariables>
          <classesDirectory>target/instrumented</classesDirectory>
          <failIfNoTests>false</failIfNoTests>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>javancss-report</id>

            <phase>verify</phase>
            <configuration>
              <target>
                <echoproperties/>

                <mkdir dir="target/javancss-reports"/>
                <xslt taskname="javancss"
                      in="target/javancss-raw-report.xml"
                      out="target/javancss-reports/javancss-report.html"
                      processor="trax"
                      classpathref="maven.plugin.classpath"
                      style="${top.root.dir}/src/test/resources/javancss2methodhtml.xsl"
                      failOnError="no">
                  <factory name="net.sf.saxon.TransformerFactoryImpl"/>
                  <param name="sourcePrefix" expression="../../src/main/java"/>
                </xslt>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>

          <execution>
            <id>cobertura-instrument</id>

            <phase>process-classes</phase> 
            <configuration>
              <target>
                <taskdef classpathref="maven.test.classpath" resource="tasks.properties"/>
                <taskdef classpathref="maven.plugin.classpath" resource="net/sf/antcontrib/antcontrib.properties"/>

                <!-- hack for the parent modules -->
                <if>
                  <or>
                    <equals arg1="${project.name}" arg2="ldr"/>
                    <equals arg1="${project.name}" arg2="ldr-mapper"/>
                    <equals arg1="${project.name}" arg2="ldr-workflow"/>
                    <equals arg1="${project.name}" arg2="ecm-workflow"/>
                    <equals arg1="${project.name}" arg2="ldr-test-merge"/>
                    <equals arg1="${project.name}" arg2="ldr-preliminary"/>
                    <equals arg1="${project.name}" arg2="ldr-cleanup"/>
                    <equals arg1="${project.name}" arg2="ldr-helpers"/>
                    <equals arg1="${project.name}" arg2="ephesoft-extraction"/>
                    <equals arg1="${project.name}" arg2="acceptance-test"/>
                  </or>

                  <then>
                    <mkdir dir="target/classes"/>
                    <mkdir dir="src/main/java"/>
                  </then>
                </if>
                <mkdir dir="target/instrumented"/>

                <cobertura-instrument todir="target/instrumented">
                  <fileset dir="target/classes">
                    <include name="**/*.class"/>
                  </fileset>
                </cobertura-instrument>

                <copy todir="target/instrumented">
                  <fileset dir="target/classes">
                    <include name="**/*"/>              
                  </fileset>
                </copy>

                <!-- hack for the parent module -->
                <if>
                  <or>
                    <equals arg1="${project.name}" arg2="ldr"/>
                    <equals arg1="${project.name}" arg2="ldr-mapper"/>
                    <equals arg1="${project.name}" arg2="ldr-workflow"/>
                    <equals arg1="${project.name}" arg2="ecm-workflow"/>
                    <equals arg1="${project.name}" arg2="ldr-test-merge"/>
                    <equals arg1="${project.name}" arg2="ldr-preliminary"/>
                    <equals arg1="${project.name}" arg2="ldr-cleanup"/>
                    <equals arg1="${project.name}" arg2="ldr-helpers"/>
                    <equals arg1="${project.name}" arg2="ephesoft-extraction"/>
                    <equals arg1="${project.name}" arg2="acceptance-test"/>
                  </or>
                  <then>
                    <delete dir="target/classes"/>
                    <delete dir="src/main/java"/>
                  </then>
                </if>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>

          <execution>
            <id>cobertura-report</id>

            <phase>verify</phase>
            <configuration>
              <target>
                <taskdef classpathref="maven.test.classpath" resource="tasks.properties"/>

                <mkdir dir="target/cobertura-reports"/>

                <cobertura-report datafile="cobertura.ser"
                                  format="xml"
                                  destdir="target/cobertura-reports"
                                  srcdir="${basedir}/src/main/java"/>

                <cobertura-report datafile="cobertura.ser"
                                  format="html"
                                  destdir="target/cobertura-reports"
                                  srcdir="${basedir}/src/main/java"/>


                <!-- cobertura-check failureproperty="cobertura.failure"
                                 datafile="${cobertura.ser.file}"
                                 haltonfailure="false"
                                 linerate="0"
                                 packagebranchrate="0"
                                 packagelinerate="0"
                                 totalbranchrate="25"
                                 totallinerate="30"/ -->
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>

        </executions>
        <dependencies>
          <dependency>
            <groupId>ant-contrib</groupId>
            <artifactId>ant-contrib</artifactId>
            <version>20020829</version>
          </dependency>
          <dependency>
            <groupId>net.sf.saxon</groupId>
            <artifactId>saxon</artifactId>
            <version>8.7</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>

</project>

我对 Maven 比较陌生。我在 Windows 平台上使用 apache-maven-3.3.3 和 J2SE 1.5。我所有的 JAVA 包都驻留在/src/main/java 中。

最佳答案

Java 1.6 中的 @Override 注释规范发生了变化。在 Java 1.5 中,编译器不允许在实现的接口(interface)方法上使用 @Override 注解,但在 1.6 中却允许。

关于java - 为什么 Maven 构建无法解析 @Override 注解?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30235375/

相关文章:

java - 无法找到到请求目标的有效证书路径

eclipse - HTTP 状态 404 - 请求的资源 (/ProjectName/) 不可用

java - 如何让Maven使用JDK1.8而不是JDK1.6

java - 在 Eclipse Luna 调试器中请求参数值

java - org.springframework.orm.hibernate4.LocalSessionFactoryBean 无法转换为 org.hibernate.SessionFactory

java - 如何使用 Maven 构建用于生产的 Javafx + Spring

java - 关于 Web 服务和 Portlet 的推荐书籍

java - 我如何保留我的距离表示得分字段并将其映射到我的结果实体中?

java - 这是否被垃圾收集?

java - 从 Spring Boot 中排除 Maven 依赖项