[flink]#10_应用开发项目搭建

Java

Maven构建

$ mvn archetype:generate                               \
      -DarchetypeGroupId=org.apache.flink              \
      -DarchetypeArtifactId=flink-quickstart-java      \
      -DarchetypeVersion=1.9.0						\
      -DarchetypeCatalog=local

IDEA 导入后进行开发

或直接在pom.xml:

<dependency>  
  <groupId>org.apache.flink</groupId>  
  <artifactId>flink-java</artifactId>  
  <version>1.6.1</version> 
<scope>provided</scope>  
</dependency>  
<dependency> 
  <groupId>org.apache.flink</groupId>  
  <artifactId>flink-streaming-java_2.11</artifactId>  
  <version>1.6.1</version>  
  <scope>provided</scope>  
</dependency>

开发时注释scope,编译打包再开启


Scala

Maven构建

$ mvn archetype:generate                               \
      -DarchetypeGroupId=org.apache.flink              \
      -DarchetypeArtifactId=flink-quickstart-scala      \
      -DarchetypeVersion=1.9.0						\
      -DarchetypeCatalog=local

IDEA 导入后进行开发

或直接在pom.xml:

<dependency>  
  <groupId>org.apache.flink</groupId>  
  <artifactId>flink-scala_2.11</artifactId>  
  <version>1.6.1</version> 
<scope>provided</scope> 
</dependency>  
<dependency>  
  <groupId>org.apache.flink</groupId>  
  <artifactId>flink-streaming-scala_2.11</artifactId>  
  <version>1.6.1</version> 
<scope>provided</scope> 
</dependency>

开发时注释scope,编译打包再开启


PS

一般的flink-java中的pom:

<dependencies> 
<!-- Apache Flink dependencies --> <!-- These dependencies are provided, because they should not be packaged into the JAR file. --> 
<dependency> 
<groupId>org.apache.flink</groupId> 
<artifactId>flink-java</artifactId> 
<version>${flink.version}</version>
 <scope>provided</scope> 
 </dependency> 
 <dependency> 
 <groupId>org.apache.flink</groupId>
  <artifactId>flink-streaming-java_${scala.binary.version</artifactId> 
<version>${flink.version}</version>
<scope>provided</scope> 
</dependency>

<!-- Add logging framework, to produce console output when running in the IDE. --> <!-- These dependencies are excluded from the application JAR by default. -> 
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.7</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<scope>runtime</scope>
</dependency>
</dependencies>

为了使打出来的 Jar 包要小,又能够在本地 IDEA 中进行运行和调试 Job

<profiles>

<profile>
<id>add-dependencies-for-IDEA</id>

<activation> <property> <name>idea.version</name> </property> </activation>

<dependencies>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-java</artifactId>
<version>${flink.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java_${scala.binary.version</artifactId>
<version>${flink.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</profile>
</profiles>

在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值