2014-04-21 259 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