鍍金池/ 問答/Java  網(wǎng)絡(luò)安全  HTML/ Java實(shí)用protobuf的話,每次定義一個(gè)新類都要用protobuf相關(guān)命令

Java實(shí)用protobuf的話,每次定義一個(gè)新類都要用protobuf相關(guān)命令生成一個(gè)類?

Java實(shí)用protobuf的話,每次定義一個(gè)新類都要用protobuf相關(guān)命令生成一個(gè)類?
這不是太麻煩了嗎?

回答
編輯回答
心沉

當(dāng)然是的。有 maven 插件可以讓你在打包的時(shí)候自動(dòng)完成這個(gè)事情,不過前提是要安裝 protoc

<plugin>
    <groupId>com.github.igor-petruk.protobuf</groupId>
    <artifactId>protobuf-maven-plugin</artifactId>
    <version>0.6.3</version>
    <executions>
        <execution>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <protocCommand>/usr/local/bin/protoc</protocCommand>
    </configuration>
</plugin>
2018年6月7日 18:02
編輯回答
老梗

用protostuff吧 protostuff基于Google protobuf,但是提供了更多的功能和更簡易的用法

2018年1月22日 02:13