2017-07-02 27 views
0

我正在使用Eclipse Oxygen,但這也是Neon版本中的問題。我已經開始了新的Maven項目並選擇了webapp-javaee7原型。該項目的創建完成後,pom.xml中已配置是這樣的:如何解決問題Eclipse未在webapp-javaee7 archetype Maven項目中顯示javax.annotation包的Javadocs?

<properties> 
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 

<dependencies> 
    <dependency> 
     <groupId>javax</groupId> 
     <artifactId>javaee-web-api</artifactId> 
     <version>7.0</version> 
     <scope>provided</scope> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.1</version> 
      <configuration> 
       <source>1.7</source> 
       <target>1.7</target> 
       <compilerArguments> 
        <endorseddirs>${endorsed.dir}</endorseddirs> 
       </compilerArguments> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.3</version> 
      <configuration> 
       <failOnMissingWebXml>false</failOnMissingWebXml> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <version>2.6</version> 
      <executions> 
       <execution> 
        <phase>validate</phase> 
        <goals> 
         <goal>copy</goal> 
        </goals> 
        <configuration> 
         <outputDirectory>${endorsed.dir}</outputDirectory> 
         <silent>true</silent> 
         <artifactItems> 
          <artifactItem> 
           <groupId>javax</groupId> 
           <artifactId>javaee-endorsed-api</artifactId> 
           <version>7.0</version> 
           <type>jar</type> 
          </artifactItem> 
         </artifactItems> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

因此,JavaEE的認可的,API-7.0.jar添加到贊同庫。正如我從this post瞭解到的,jar文件包含Annotations包javax.annotation。

我已經將包javax.annotation導入到此項目中的一些類中,並使用了一些註釋。當我將鼠標懸停在某些註釋上時,我收到以下消息:Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.

當我嘗試在瀏覽器中打開「附加的」Javadoc時,出現警告對話框:The documentation location for (annotation name) has not been configured. For elements from libraries specify the Javadoc location URL on properties page of the parent JAR ...\target\endorsed\javaee-endorsed-api-7.0.jar

將源代碼或Javadoc附加到javaee-endorsed-api-7.0.jar是不可能的。

當我製作普通Java項目並使用javax.annotation包時,Javadocs按預期方式顯示。

如何解決這個問題,並讓Eclipse在此Maven項目中顯示用於javax.annotation包的Javadocs我正在處理?

謝謝。

回答

1

我在this post的評論中找到了此問題的解決方案。該解決方案是項目的基礎上:

  • 選擇特定項目
  • 轉到項目 - >屬性 - > Java構建路徑 - >在線訂單和出口
  • 重排庫,直到出現的Javadoc。

對我來說,它有助於將JRE系統庫放置在支持庫之上。這意味着Eclipse將按照此選項卡指定的順序從庫中拉取javadoc。而且由於所有用於註釋的javadoc都是在放置在jdk安裝的適當目錄中的javadoc中定義的(在此選項卡上註釋爲JRE系統庫),現在它們在Eclipse中按預期顯示。

solving issu This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.

0

它可能是依賴性問題,或者可能是JDK和JRE版本,我可以在JDK 8上試用此版本,並使用javaee-web-api的6.0版本。你也可以將答案轉換成stackoverflow鏈接here

0

您的解決方案並沒有爲我工作(?也許我只是沒有重新排序他們足夠的時間),但以防其他人遇到了同樣的問題,這個工作馬上對我說:

我刪除了所有庫(項目,庫),清理項目,以便所有缺失的依賴項都會顯示爲錯誤,然後添加它們並再次清理配置文件。也許這可以幫助某人

相關問題