Open ppdouble opened 1 year ago
pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>nd.pemo</groupId> <artifactId>thrift-rpc-sample-client</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>org.apache.thrift</groupId> <artifactId>libthrift</artifactId> <version>0.18.1</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.25</version> </dependency> </dependencies> <build> <defaultGoal>clean generate-sources compile install</defaultGoal> <plugins> <plugin> <groupId>org.apache.thrift.tools</groupId> <artifactId>maven-thrift-plugin</artifactId> <version>0.1.11</version> <configuration> <generator>java</generator> <thriftExecutable>/usr/bin/thrift</thriftExecutable> <thriftSourceRoot>${basedir}/src/main/resources/thrift</thriftSourceRoot> <outputDirectory>${basedir}/src/main/java/thrift</outputDirectory> </configuration> <executions> <execution> <id>thrift-sources</id> <phase>generate-sources</phase> <goals> <goal>compile</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> </project>
namespace java thrift.rpc.api.user namespace cpp thrift.rpc.api.user struct LoginRequest { 1: string username, 2: string password } struct APIResponse { 1: string responsemessage, 2: i32 responseCode } # empty for logout request struct Empty { } # specific response for logout struct LogoutResponse { 1: string logoutmessage, 2: i32 responseCode } service User { APIResponse login(1:LoginRequest loginRequest); LogoutResponse logout(1:Empty empty); }
The namespace java thrift.rpc.api.user will append another thrift to <outputDirectory>${basedir}/src/main/java/thrift</outputDirectory>. So, it will be src/main/java/thrift/thrift/rpc/api/user. The package of generated classes would be wrong.
namespace java thrift.rpc.api.user
thrift
<outputDirectory>${basedir}/src/main/java/thrift</outputDirectory>
src/main/java/thrift/thrift/rpc/api/user
pom.xml
The
namespace java thrift.rpc.api.user
will append anotherthrift
to<outputDirectory>${basedir}/src/main/java/thrift</outputDirectory>
. So, it will besrc/main/java/thrift/thrift/rpc/api/user
. The package of generated classes would be wrong.