2014-04-21 494 views
2

問題:我試圖讓谷歌協議緩衝區依賴關係工作。但沒有結果。 Maven不能拉任何協議緩衝區的依賴關係。Maven ArtifactNotFoundException疑難解答

Question1:據我所知,這個依賴在標準的maven倉庫中是不存在的,所以我只需要指出一些額外的倉庫。 我對不對?

問題2:如果回答第一個問題是,不是我怎麼能獲得額外的存儲庫的網址是什麼?Here是對maven依賴關係的引用。

錯誤:

[ERROR] Plugin com.google.protobuf.tools:maven-protoc-plugin:0.3.2 or one of its dependencies could not be resolved: Failure to find com.google.protobuf.to 
ols:maven-protoc-plugin:jar:0.3.2 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the u 
pdate interval of central has elapsed or updates are forced -> [Help 1] 
org.apache.maven.plugin.PluginResolutionException: Plugin com.google.protobuf.tools:maven-protoc-plugin:0.3.2 or one of its dependencies could not be resol 
ved: Failure to find com.google.protobuf.tools:maven-protoc-plugin:jar:0.3.2 in http://repo.maven.apache.org/maven2 was cached in the local repository, res 
olution will not be reattempted until the update interval of central has elapsed or updates are forced 
     ....... 
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Failure to find com.google.protobuf.tools:maven-protoc-plugin:jar:0.3.2 in http://rep 
o.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or update 
s are forced 

的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>groupId</groupId> 
    <artifactId>JavaSockets</artifactId> 
    <version>1.0-SNAPSHOT</version> 

    <dependencies> 
     <dependency> 
      <groupId>com.google.protobuf</groupId> 
      <artifactId>protobuf-java</artifactId> 
      <version>2.5.0</version> 
     </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> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>com.google.protobuf.tools</groupId> 
       <artifactId>maven-protoc-plugin</artifactId> 
       <version>0.3.2</version> 
       <configuration> 
        <protocExecutable>C:\Users\Clasik\Desktop\Java Sockets</protocExecutable> 
       </configuration> 
       <executions> 
        <execution> 
         <goals> 
          <goal>compile</goal> 
          <goal>testCompile</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 


     ...... 
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Failure to find com.google.protobuf.tools:maven-protoc-plugin:jar:0.3.2 in http://repo.ma 
ven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates ar 
e forced 
    ............... 
+0

HTTP這個插件庫以獲得版本0.3.2://計算器.com/questions/17841931/maven-protoc-plugin-configuration-in-pom-xml-incorrect –

+0

@FlorescentTicker他們沒有提供如何用maven解決這個問題的答案。他們只是建議手動下載插件。此外,我已經解決了這個問題 –

回答

2

缺少的依賴是maven-protoc-plugin,不是原始的BUF-java的。這個插件是not available in Maven Central

根據它的作者,您可以添加自託管庫的pom.xml中:

<pluginRepositories> 
    <pluginRepository> 
     <id>protoc-plugin</id> 
     <url>http://sergei-ivanov.github.com/maven-protoc-plugin/repo/releases/</url> 
    </pluginRepository> 
</pluginRepositories> 

但我只得到404這裏。因此,您可以聯繫作者或查看源代碼並手動在本地存儲庫中安裝插件。

+0

除了pom.xml中的plugin \ dependencies定義之外,我還應該包含一些proto緩衝區的源代碼嗎?當我嘗試'mvn clean install'時,我得到'找不到符號'錯誤,比如'MessageOrBuilder','Parser'等等。據我所知,協議緩衝庫 –

+0

你現在在使用dtrott還是ivanov的版本?請與相應的文件進行比較。例如,Dtrott在版本2.3.0中使用protobuf-java。也許2.5.0帶來了不兼容的變化。 (只是猜測...) – lefloh

+0

我已經切換到ivanov版本。我該怎麼辦。如果我在GitHub上發佈我的演示,並且你會發生什麼問題,可能會更好? –

0

的解決方案是增加插件庫:

<pluginRepositories> 
    <pluginRepository> 
     <id>dtrott</id> 
     <url>http://maven.davidtrott.com/repository</url> 
    </pluginRepository> 
</pluginRepositories> 
+0

在那裏你只會找到版本0.1.10。配置的版本0.3.2來自[this fork](https://github.com/sergei-ivanov/maven-protoc-plugin) – lefloh

+0

@lefloh據我所知你打算改變'pluginRepository'的定義。你可以在單獨的答案中提供你的版本嗎? –

+0

我已經回答。但問題是fork的maven-repository似乎已經關閉了。 – lefloh

0

這個插件的舊版本可從Bintray:

<pluginRepositories> 
    <pluginRepository> 
    <id>protoc-plugin</id> 
    <url>https://dl.bintray.com/sergei-ivanov/maven</url> 
    </pluginRepository> 
</pluginRepositories> 

我能夠使用鏈接到項目readme