Java Build Finagle

Source: Internet
Author: User

1. New MAVEN Project

2. Pom File Add dependency

Add 3 main dependencies
<Dependency> <groupId>Com.twitter</groupId> <Artifactid>scrooge-core_2.10</Artifactid> <version>${scrooge.version}</version> </Dependency> <Dependency> <groupId>Com.twitter</groupId> <Artifactid>finagle-thrift_2.10</Artifactid> <version>${finagle.version}</version> </Dependency> <Dependency> <groupId>Com.twitter</groupId> <Artifactid>finagle-serversets_2.10</Artifactid> <version>${finagle.version}</version> <Exclusions> <exclusion> <groupId>Org.slf4j</groupId> <Artifactid>Slf4j-jdk14</Artifactid> </exclusion> </Exclusions> </Dependency>
PS: for note useFinagle.version 6.20.0
Then add the dependency source Note: This URL is the wall please configure the agent in Maven.
<repositories>
<repository>
<id>twitter-twttr</id>
<url>http://maven.twttr.com/</url>
</repository>
</repositories>

3. Then configure a plugin to generate Java files from the thrift file (this plugin is important)

In<Build>Of<Plugins>The following configuration<plugin>      <groupId>Com.twitter</groupId>      <Artifactid>Scrooge-maven-plugin</Artifactid>      <version>${scrooge.version}</version>      <Configuration>          <thriftnamespacemappings>              <thriftnamespacemapping>                  < from>Com.twitter.demo</ from>                  < to>xxxxxxxx</ to>              </thriftnamespacemapping>          </thriftnamespacemappings>          <language>Java</language> <!--default is Scala -          <thriftopts>              <!--Add other Scrooge command line options using Thriftopts -              <thriftopt>--finagle</thriftopt>              <!--<thriftOpt>\-\-ostrich</thriftOpt> -          </thriftopts>          <!--Tell Scrooge to extract thrifts from these artifacts -          <Dependencyincludes>              <include>Event-logger-thrift</include>          </Dependencyincludes>      </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>
Note: Red part to need to fill in the desired package name, that is, the package name of the generated file

4. Create a new Thrift folder (and Java folder sibling) under Project file Src/main

New Thrift File: Write Thrift: No wordy. The compilation will then automatically generate thrift corresponding Java files.

5, according to Java files inherit xxx. Serveriface implementation-defined interfaces

Java Build Finagle

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.