thrift maven编译运行

| 2015年5月22日

dependencies编译,pom.xml中加入build配置:

<build >
    <sourceDirectory> src/main/java </sourceDirectory>
    <plugins>
            <!-- Bind the maven-assembly-plugin to the package phase this will create
                a jar file without the storm dependencies suitable for deployment to a cluster. -->
            <plugin>
                <artifactId> maven-assembly- plugin</artifactId>
                <configuration>
                        <descriptorRefs>
                                <descriptorRef> jar-with-dependencies </descriptorRef >
                        </descriptorRefs>
                        <archive>
                                <manifest>
                                        <mainClass></mainClass >
                                </manifest>
                        </archive>
                </configuration>
                <executions>
                        <execution>
                                <id> make-assembly </id >
                                <phase> package</phase >
                                <goals>
                                        <goal> single</goal >
                                </goals>
                        </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId> org.apache.maven.plugins </groupId >
                <artifactId> maven-compiler- plugin</artifactId>
                <configuration>
                        <source> 1.7</source >
                        <target> 1.7</target >
                </configuration>
            </plugin>

            <plugin>
                <groupId> org.apache.maven.plugins </groupId >
                <artifactId> maven- surefire-plugin </artifactId >
                <configuration>
                        <skip> true</skip ><!-- 跳过测试用例 -->
                </configuration>
            </plugin>

    </plugins>
</build>

thrift依赖:

<dependencies >
<dependency >
    <groupId > junit</groupId>
    <artifactId > junit</artifactId>
    <version >3.8.1 </version>
    <scope >test </scope>
</dependency >

    <dependency>
        <groupId> org.apache.thrift </groupId >
        <artifactId> libthrift </artifactId >
        <version> 0.9.2</version >
    </dependency>
    <dependency>
            <groupId> org.slf4j </groupId >
            <artifactId> slf4j-log4j12 </artifactId >
            <version> 1.5.8</version >
    </dependency>
</dependencies >

运行jar包:

E:\idata_spark_work\test\target>java -cp .\test-0.0.1-SNAPSHOT-jar-with-dependencies.jar org.zhwen.test.HelloServerDemo
E:\idata_spark_work\test\target>java -cp .\test-0.0.1-SNAPSHOT-jar-with-dependencies.jar org.zhwen.test.HelloClientDemo
看完本文有收获?请分享给更多人

关注「黑光技术」,关注大数据+微服务