一些知识点参考于:https://blog.youkuaiyun.com/u010900754/article/details/80172671
1、thrift服务不支持重载(因为thrift支持多语言,有的语言是不支持重载的)。
2、thrift文件名要小写(xxx.thrift)。
3、可以include其他jar包中的thrift文件(include "user_rights_resp.thrift")
4、maven中插件
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.thrift.tools</groupId>
- <artifactId>maven-thrift-plugin</artifactId>
- <version>0.1.11</version>
- <configuration>
- <!--<thriftExecutable>/usr/local/bin/thrift</thriftExecutable>-->
- <!--<thriftSourceRoot>src/main/thrift</thriftSourceRoot>-->
- <!--<outputDirectory>src/main/java</outputDirectory>-->
- </configuration>
- <executions>
- <execution>
- <id>thrift-sources</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>compile</goal>
- </goals>
- </execution>
- <!--<execution>-->
- <!--<id>thrift-test-sources</id>-->
- <!--<phase>generate-test-sources</phase>-->
- <!--<goals>-->
- <!--<goal>testCompile</goal>-->
- <!--</goals>-->
- <!--</execution>-->
- </executions>
- </plugin>
- </plugins>
- </build>
thriftExecutable,指的是thrift编译器的位置,如果我们配置了环境变量(推荐),可以不指定。验证环境变量可以使用thrift --version命令。
thriftSourceRoot,thrift源文件(xxxx.thrift文件)的目录,默认会从src/main/thrift下读取。