Maven和Protobuf编译错误:在com.google.protobuf包中找不到符号

凯蒂:

我是Linux和Protobuf的新手。我需要帮助。

我正在尝试“ mvn包”一个包含许多“ .proto”文件和一个pom.xml文件的项目……

我正在使用Ubuntu

======================================

错误

当我运行“ mvn软件包”时,出现以下错误:

...
Compiling 11 source files to .../target/classes
...

我收到很多这样的错误:

[ERROR] .../target/generated-sources/...java:[16457,30] cannot find symbol
[ERROR] symbol  : class Parser
[ERROR] location: package com.google.protobuf
[ERROR] 
[ERROR] .../target/generated-sources/...java:[17154,37] cannot find symbol
[ERROR] symbol  : class Parser
[ERROR] location: package com.google.protobuf
[ERROR] 
[ERROR] .../target/generated-sources/...java:[17165,30] cannot find symbol
[ERROR] symbol  : class Parser
[ERROR] location: package com.google.protobuf
[ERROR] 
[ERROR] .../target/generated-sources/...java:[17909,37] cannot find symbol
[ERROR] symbol  : class Parser
[ERROR] location: package com.google.protobuf
[ERROR]

======================================

聚甲醛

这是pom.xml文件,其中已删除groupId和artifactId:

<project>
  <modelVersion>4.0.0</modelVersion>
  <parent>
     <groupId>*****</groupId>
     <artifactId>*****</artifactId>
     <version>1.0-SNAPSHOT</version>
  </parent>
  <artifactId>*****</artifactId>
  <version>1.0-SNAPSHOT</version>
  <properties>
      <proto.cas.path>${project.basedir}/src</proto.cas.path>
      <target.gen.source.path>${project.basedir}/target/generated-sources</target.gen.source.path>
  </properties>
 <dependencies>
      <dependency>
                <groupId>com.google.protobuf</groupId>
                <artifactId>protobuf-java</artifactId>
                <version>2.4.1</version>
                <scope>compile</scope>
            </dependency>
  </dependencies>
  <build>
    <sourceDirectory>${project.basedir}/src</sourceDirectory>
        <plugins>
            <plugin>
               <artifactId>maven-compiler-plugin</artifactId>
               <version>2.0.2</version>
               <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                    <includes><include>**/commonapps/**</include></includes>
                </configuration>            
             </plugin>
             <plugin>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>generate-sources</id>
                            <phase>generate-sources</phase>
                            <configuration>
                                <tasks>
                                    <mkdir dir="${target.gen.source.path}" />    
                                    <path id="proto.path.files">
                                        <fileset dir="${proto.cas.path}">
                                            <include name="*.proto" />
                                        </fileset>  
                                    </path>
                                    <pathconvert pathsep=" " property="proto.files" refid="proto.path.files" />

                                    <exec executable="protoc">
                                         <arg value="--java_out=${target.gen.source.path}" />
                                         <arg value="--proto_path=${proto.cas.path}" />
                                            <arg line="${proto.files}" />
                                    </exec>
                                </tasks>
                                <sourceRoot>${target.gen.source.path}</sourceRoot>
                            </configuration>
                            <goals>
                                <goal>run</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
         </plugins>
     </build>
</project>

======================================

PROTOBUF安装

我弄完了

./configure
make
make check
make install

在protobuf /中,

mvn test
mvn install
mvn package

在protobuf / java中。

我把瓶子放在protobuf / java / target

并通过运行将其添加到我的Maven仓库中:

mvn install:install-file -Dpackaging=jar -DgeneratePom=true  -DgroupId=com.google.protobuf   -DartifactId=protobuf-java   -Dfile=protobuf-java-2.4.1.jar -Dversion=2.4.1

请注意,我已经弄乱了$ LD_LIBRARY_PATH。当前,当我运行echo时,我得到:

/usr/local/lib/:/usr/:/usr/lib/:/usr/local/

是的....正如您所知,我对设置$ LD_LIBRARY_PATH毫无头绪

我还跑了:

apt-get install protobuf-compiler

======================================

协议安装

我忘记了做protoc的工作,但是当我跑步时

protoc --version

我懂了

libprotoc 2.5.0

======================================

我的问题类似于:

在Java和Scala中使用protobufs的问题

Maven编译失败

======================================

可能相关吗?

在“ MVN安装”后仍找不到包

http://www.scriptol.com/programming/protocol-buffers-tutorial.php

有人可以帮忙吗?

======================================

进展

显然是插件失败:

https://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project casprotobuf: Compilation failure: Compilation failure:
thesonix:

我有同样的问题。直接从Google构建protobuf来源(我使用2.5.0)并执行

mvn install:install-file -Dpackaging=jar -DgeneratePom=true  -DgroupId=com.google.protobuf   -DartifactId=protobuf-java   -Dfile=protobuf-java-2.5.0.jar -Dversion=2.5.0

为我解决了问题。

在我的早期试用中,我注意到/root/.m2/repository/com/google/protobuf/protobuf-java/2.5.0/中的jar文件丢失了。

也许尝试在pom.xml中使用2.5.0版和/或手动复制jarfile。

干杯

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

编译错误-在Redhat“ Openshift”应用程序中找不到com.google.gson包

CMake在编译Google的protobuf示例时找不到protobuf

错误:找不到模块“ google-protobuf”

Maven编译错误:找不到符号

错误:协议失败:google / protobuf / wrappers.proto:找不到文件。(Maven构建中的错误)

Maven错误:在包中找不到符号类

编译错误:找不到符号:In,StdIn和StdOut

在相同的程序包和目录中找不到符号

Java中的编译错误:找不到符号

Java编译错误:找不到符号

Java编译错误:找不到符号

在Google云端功能中找不到软件包“ firebase.google.com/go”

编译错误-由以下原因引起:java.lang.ClassNotFoundException:在android studio中找不到类“ com.google.android.gms.common.internal.zzbo”

Google Kick Start Tests中的编译错误和运行时错误

从com.google.android.exoplayer2.upstream.ResolvingDataSource中找不到符号`ResolvingDataSource`

在com.google.firebase.messaging.FirebaseMessagingService中找不到符号“ messaging”

Maven中的编译错误

protobuf 类中的 Remy 源代码(github)编译错误

如何避免找不到包“ github.com/golang/protobuf/jsonpb”错误

Maven:没有编译错误,但仍然找不到符号

Maven项目编译错误:找不到符号(这是java.lang.String)

错误:找不到符号-Java编译错误

找不到包 com.google.tango.support

Android Studio中突然发生编译错误;错误:找不到符号类ComputableLiveData

Android Studio中的Google登录按钮丝毫Firebase,错误:找不到符号变量default_web_client_id

从其他文件导入消息时Protobuf编译错误

gradle生成protobuf类,但显示编译错误

如何修复 OSX 上的 tensorflow protobuf 编译错误?

编译错误:在Android Studio中找不到符号AudioEffect :: setParameter