Protobuf-java maven Configuration

Source: Internet
Author: User
Protobuf-java maven Configuration
1. Maven Pom Fragment

          <!--Protobuf-java for maven plugin Http://stackoverflow.com/questions/1578456/integrate-prot
              Ocol-buffers-into-maven2-build Execute failed:java.io.IOException:Cannot Run Program "PROTOC":
                 Complile and install compiler the PROTOC: # git clone https://github.com/google/protobuf #./autogen.sh #/configure # make && make check # sudo m Ake install after all, compile a proto to java (= = means two minus signs): # protoc-i= $SRC _dir ==java_out= $DST _dir user.proto--> <plugin> <artifactid>maven-
                        Antrun-plugin</artifactid> <executions> <execution>
                        <id>generate-sources</id> <phase>generate-sources</phase> <configuration> <tasks> <mkdir dir= "src/main/java/avro/
                                    Channel/protobuf "/> <exec failonerror=" true "executable=" Protoc ">
                                    <arg value= "--java_out=src/main/java/avro/channel/protobuf"/> <arg value= "Src/avro/user.proto"/> </exec> <
                        /tasks> <sourceRoot>src/main/java/avro/channel/protobuf</sourceRoot> </configuration> <goals> <goal>run< /goal> </goals> </execution> </executions&gt
            ;
            </plugin> </plugins> </build> <dependencies> <dependency> <grouPid>com.google.protobuf</groupid> <artifactId>protobuf-java</artifactId> < Version>${protobuf-java.version}</version> </dependency> </dependencies>

2. User.proto

Option Java_package = "Avro.channel.protobuf";
Option Java_outer_classname = "Reg";

Message User {
    Required String ipaddr = 1;
    Optional String cookie = 2;
    Optional Int64 token = 3;
}


3. Installation protobuf 1) Download

Https://github.com/google/protobuf/releases

$ wget--no-check-certificate https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz
2) Installation
$ TAR-ZXF protobuf-2.6.1.tar.gz

$ cd protobuf-2.6.1/

$/configure $ make

check sudo-make

install
3) under Ubuntu

$ sudo cd/etc/ld.so.conf.d/

$ sudo touch libprotobuf.conf

$ sudo echo "/usr/local/lib" >> libprotobuf.conf

$ sudo ldconfig

4) Inspection

$ protoc--version

Libprotoc 2.6.1


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.