protobuf 生成对应的文件

来源:互联网 发布:华为查看mac表ip 编辑:程序博客网 时间:2024/05/16 15:57

protoc –java_out=../ –proto_path= .\addressbook.proto

上面的是根据proto文件生成java文件.

1,其中–java_out=../ 表示输出java在当前的目录下
2.表示–proto_path= .\addressbook.proto proto的目录 ./代表当前的目录.
3.建议还是根据就官方的来吧.我现在用上面的指令运行不了


上面的以前写的,辣鸡。看这里进行编译就可以了。。
4.用下面的语句我编译出来了。重点是./ 当前目录 后面直接跟空格 addressbook.proto然后资源文件

E:\worktemp\googleprotobuf>protoc.exe –java_out=./ addressbook.proto


如果报

Unknown flag: -j
错误说明:你需要两个破折号

如果报input file not find

If you haven't installed the compiler, download the package and follow the instructions in the README.Now run the compiler, specifying the source directory (where your application's source code lives – the current directory is used if you don't provide a value), the destination directory (where you want the generated code to go; often the same as $SRC_DIR), and the path to your .proto. In this case, you...:**protoc -I=$SRC_DIR --java_out=$DST_DIR $SRC_DIR/addressbook.proto**Because you want Java classes, you use the --java_out option – similar options are provided for other supported languages.

protoc -I=SRCDIRjavaout=DST_DIR $SRC_DIR/addressbook.proto
就是直接使用官方的配置吧.
上面的写的不对
参考链接

0 0