我正在尝试将protobuf依赖添加到我的maven项目中。我已经使用mvn install:install-file -Dpackaging=jar\ -DgeneratePom=true\安装了protobuf jar文件。
-DgroupId=com.google.protobuf\ -DartifactId=protobuf-java\ -Dfile=protobuf-java-2.5.0.jar\ -Dversion=2.5.0Mypom.xml文件如下:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ProtobufExample</groupId>
<artifactId>ProtobufTest</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>ProtobufTest</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<skip.tests>false</skip.tests>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.4.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>ProtobufTest</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<finalName>${project.name}-${project.version}</finalName>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<finalName>${project.name}-${project.version}</finalName>
<descriptors>
<descriptor>src/assembly/dist.xml</descriptor>
</descriptors>
</configuration>
</plugin>
<plugin>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.5.0</version>
<executions>
<execution>
<id>generate-sources</id>
<goals>
<goal>test</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<protoSourceRoot>${basedir}/src/main/proto/</protoSourceRoot>
<includes>
<param>**/*.proto</param>
</includes>
</configuration>
</execution>
</executions>
<configuration>
<protocExecutable>/usr/local/bin/protoc</protocExecutable>
</configuration>
</plugin>
</plugins>
</build>
当我尝试使用"mvn test“测试它时,我得到了以下错误:无法解析com.google.protobuf的插件描述符:protobuf-java:2.5.0在META-INF/maven/plugin.xml中找不到插件描述符
请帮我找出我哪里错了。
发布于 2013-05-21 19:11:45
该问题是根据您的pom文件的以下代码片段定位的:
<plugin>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.5.0</version>
<executions>
<execution>
<id>generate-sources</id>
<goals>
<goal>test</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<protoSourceRoot>${basedir}/问题是protobuf-java is 而不是a plugin。所以这不可能是真的。
https://stackoverflow.com/questions/16668434
复制相似问题