Checker框架无法解析符号<annotatedjdk> $ {org.checkerframework:jdk8:jar} </annotatedjdk>问题

时间:2018-05-14 17:44:27

标签: maven intellij-idea checker-framework

我试图通过Maven存储库添加Checker Framework我跟着checker框架手册steps但是我在intelij ide上出现了这个错误

Cannot resolve symbol

其他人在Google groups上提到同样的问题,欢迎任何帮助

我的maven包就像这样

  <properties>
    <annotatedJdk>${org.checkerframework:jdk8:jar}</annotatedJdk>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
        <groupId>org.checkerframework</groupId>
        <artifactId>checker-qual</artifactId>
        <version>2.5.1</version>
    </dependency>
    <dependency>
        <groupId>org.checkerframework</groupId>
        <artifactId>jdk8</artifactId>
        <version>2.5.1</version>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.6.1</version>
          <configuration>
            <source>1.8</source>
            <target>1.8</target>
            <compilerArguments>
              <Xmaxerrs>10000</Xmaxerrs>
              <Xmaxwarns>10000</Xmaxwarns>
            </compilerArguments>
            <annotationProcessorPaths>
              <path>
                <groupId>org.checkerframework</groupId>
                <artifactId>checker</artifactId>
                <version>2.5.1</version>
              </path>
            </annotationProcessorPaths>
            <annotationProcessors><annotationProcessor>org.checkerframework.checker.nullness.NullnessChecker</annotationProcessor>
            </annotationProcessors>
            <compilerArgs>
              <arg>-AprintErrorStack</arg>
              <arg>-Xbootclasspath/p:${annotatedJdk}</arg>
            </compilerArgs>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <executions>
            <execution>
              <goals>
                <goal>properties</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.7.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.20.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
      </plugins>
    </pluginManagement>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <configuration>
                  <source>8</source>
                  <target>8</target>
              </configuration>
          </plugin>
      </plugins>
  </build>

告诉我,如果错过任何步骤,它也不允许删除该行错误

2 个答案:

答案 0 :(得分:0)

假设项目是由Maven从命令行正确构建的,这看起来像IntelliJ IDEA突出显示问题:IDEA-129269 / IDEA-187553

答案 1 :(得分:0)

我能够避免此问题的方法是声明属性,如下所示:

<checkerframework.version>2.5.6</checkerframework.version>
<annotatedJdk>${settings.localRepository}/org/checkerframework/jdk8/${checkerframework.version}/jdk8-${checkerframework.version}.jar</annotatedJdk>

然后重新导入Maven项目。

还请注意,使用此方法也不一定需要配置maven-dependency-plugin