2016-11-15 149 views
3

我試圖從當前的Maven依賴項更改爲另一個。除此之外,這個其他的依賴關係幾乎完全提供了與當前的依賴關係相同的功能,因爲當前的依賴關係是另一個依賴關係的老版本的一個分支。要做到這一點,我有:Eclipse沒有看到Maven的依賴關係

  1. 改變舊的依賴關係的所有引用的POM到新的依賴
  2. 刪除並重新導入項目在Eclipse
  3. maven clean install

但是,我仍然遇到與開頭相同的問題:

  1. Eclipse沒有看到任何類依賴關係。它甚至不提供導入它們。
  2. 在該項目試圖mvn clean package,Maven的失敗,出現以下錯誤消息編譯:

    [ERROR] Failed to execute goal on project eet-demo-maven: Could not resolve dependencies for project cz.tomasdvorak:eet-demo-maven:jar:1.0-SNAPSHOT: Failed to collect dependencies at com.github.todvorak:eet-client:jar:1.3.2: Failed to read artifact descriptor for com.github.todvorak:eet-client:jar:1.3.2: Could not transfer artifact com.github.todvorak:eet-client:pom:1.3.2 from/to jitpack.io (https://jitpack.io): Not authorized , ReasonPhrase:Repo not found or no access token provided. -> [Help 1]

我已經檢查錯別字的POM和版本的正確性,所以那些不該」不成問題。我懷疑這與依賴關係/依賴關係管理/ jitpack以及它們的工作方式有關。我從來沒有真正感動他們;那裏的所有內容都可以從我爲該項目準備的開始代碼中複製而來,或者隨後與Maven一起擺動,其中我幾乎是完整的初學者。我看了一下this的問題,並嘗試了那裏的解決方案,但沒有一個適用於我的案例。

我該如何讓Maven再次看到依賴項及其傳遞依賴項,並正確編譯項目?

POM:

<?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> 

    <build> 
     <plugins> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <version>2.10</version> 
       <executions> 
        <execution> 
         <id>copy-dependencies</id> 
         <phase>package</phase> 
         <goals> 
          <goal>copy-dependencies</goal> 
         </goals> 
         <configuration> 
          <outputDirectory>${project.build.directory}</outputDirectory> 
          <overWriteReleases>false</overWriteReleases> 
          <overWriteSnapshots>false</overWriteSnapshots> 
          <overWriteIfNewer>true</overWriteIfNewer> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 

      <plugin> 
       <groupId>com.akathist.maven.plugins.launch4j</groupId> 
       <artifactId>launch4j-maven-plugin</artifactId> 
       <executions> 
        <execution> 
         <id>l4j-clui</id> 
         <phase>package</phase> 
         <goals> 
          <goal>launch4j</goal> 
         </goals> 
         <configuration> 
          <dontWrapJar>true</dontWrapJar> 
          <headerType>console</headerType> 
          <jar>eet-demo-maven-1.0-SNAPSHOT.jar</jar> 
          <outfile>target\EETSender.exe</outfile> 
          <errTitle></errTitle> 
          <cmdLine></cmdLine> 
          <chdir>.</chdir> 
          <priority>normal</priority> 
          <downloadUrl>http://java.com/download</downloadUrl> 
          <supportUrl></supportUrl> 
          <stayAlive>true</stayAlive> 
          <restartOnCrash>true</restartOnCrash> 
          <manifest></manifest> 
          <icon></icon> 
          <singleInstance> 
           <mutexName>EETMutex</mutexName> 
           <windowTitle></windowTitle> 
          </singleInstance> 
          <classpath> 
           <mainClass>cz.tomasdvorak.eetdemo.Main</mainClass> 
          </classpath> 
          <jre> 
           <path></path> 
           <bundledJre64Bit>false</bundledJre64Bit> 
           <bundledJreAsFallback>false</bundledJreAsFallback> 
           <minVersion>1.6.0_1</minVersion> 
           <maxVersion></maxVersion> 
           <jdkPreference>preferJre</jdkPreference> 
           <runtimeBits>64/32</runtimeBits> 
          </jre> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 

<plugin> 
    <artifactId>maven-jar-plugin</artifactId> 
    <configuration> 
     <archive> 
      <manifest> 
       <addClasspath>true</addClasspath> 
       <mainClass>cz.tomasdvorak.eetdemo.Main</mainClass> 
      </manifest> 
     </archive> 
     <descriptors> 
      <descriptor>assembly.xml</descriptor> 
     </descriptors> 
    </configuration> 
</plugin> 

</plugins> 
    </build> 

    <groupId>cz.tomasdvorak</groupId> 
    <artifactId>eet-demo-maven</artifactId> 
    <version>1.0-SNAPSHOT</version> 

    <repositories> 
     <repository> 
      <id>jitpack.io</id> 
      <url>https://jitpack.io</url> 
     </repository> 
    </repositories> 

    <dependencies> 
     <dependency> 
      <groupId>com.github.todvorak</groupId> 
      <artifactId>eet-client</artifactId> 
      </dependency> 
    </dependencies> 

    <dependencyManagement> 
     <dependencies> 
      <dependency> 
       <groupId>com.github.todvorak</groupId> 
       <artifactId>eet-client</artifactId> 
       <version>1.3.2</version> 
      </dependency> 
     </dependencies> 
    </dependencyManagement> 
</project> 

編輯:The dependency in question on GitHub

編輯2:我改變了POM如下,我顯然已經平息的Maven的精神再次進入建設項目。 Eclipse讓我導入了之前看不到的所有東西。然而,這種突然的思想轉變的解釋仍然是他的問題的一個有價值的結論。

<project> 
. 
. 
. 
    <dependencies> 
    <dependency> 
     <groupId>com.github.todvora</groupId> 
     <artifactId>eet-client</artifactId> 
     <version>1.3.2</version> 
    </dependency> 
    </dependencies> 
<!-- 
    <dependencyManagement> 
     <dependencies> 
      <dependency> 
       <groupId>com.github.todvorak</groupId> 
       <artifactId>eet-client</artifactId> 
       <version>1.3.2</version> 
      </dependency> 
     </dependencies> 
    </dependencyManagement> 
    --> 
</project> 
+1

似乎是一個依賴關係不能下載。也許是因爲權利,或者可能還沒有部署。你可以手動下載依賴com.github.todvorak:eet-client:jar:1.3.2'嗎? –

+0

這似乎是如此。我不明白你的意思,但你可以通過GitHub上的「克隆或下載」按鈕來獲取它,它位於JitPack按鈕下。 – Sargon1

+0

然後它可能會被部署,嘗試使用您的Maven設置手動下載文件等。請參閱http://stackoverflow.com/questions/1895492/how-can-i-download-a-specific-maven-artifact-in-關於如何調用它的一個命令行。如果它被下載,那麼問題在別的地方,但我有點懷疑...... –

回答

2

的依賴應該是:

<dependencies> 
    <dependency> 
     <groupId>com.github.todvora</groupId> 
     <artifactId>eet-client</artifactId> 

    </dependency> 
</dependencies> 

<dependencyManagement> 
    <dependencies> 
     <dependency> 
      <groupId>com.github.todvora</groupId> 
      <artifactId>eet-client</artifactId> 
      <version>1.3.2</version> 
     </dependency> 
    </dependencies> 
</dependencyManagement> 

你添加一個額外的K至tordova

+0

是真的。出於某種原因,當我傾銷並將版本添加到適當的時,它會再次運行。我想我太習慣於自動完成和拼寫檢查。當我從JitPack複製自動生成的pom行以添加依賴項時,我無意中糾正了錯誤。 – Sargon1