2016-09-30 135 views
6

我必須遵循this教程,以使用maven爲我的Apache Spark應用程序創建一個超級jar。Apache Spark Maven用於發佈和開發應用程序的依賴關係

我已經在pom中設置了所有的Spark依賴關係<scope>provided</scope>。 這工作得很好,但現在當我在本地運行應用程序時,我得到一個錯誤,遺漏了Spark的依賴關係。

目前我不得不從pom中刪除provided標籤。

只有在構建發佈應用程序時,我如何才能提供Spark依賴關係?

我使用Intellij作爲開發應用程序的IDE。

回答

1

您可以創建單獨的Maven配置文件。

最好的辦法是在POM dependencyManagment部分,在那裏你會指定版本,那麼在配置文件中,你將有唯一的groupId +的artifactId +範圍

例如:

<profile> 
    <id>dev</id> 
    <activation> 
     <activeByDefault>false</activeByDefault> 
    </activation> 
    <dependencies> 
    <!-- Here Spark deps without provided --> 
     <dependency> 
      <groupId>...</groupId> 
      <artifactId>...</artifactId> 
      <scope>compile</scope> 
     </dependency> 
    </dependencies> 
</profile> 
<profile> 
    <id>prod</id> 
    <dependencies> 
    <!-- Here Spark deps with provided --> 
     <dependency> 
      <groupId>...</groupId> 
      <artifactId>...</artifactId> 
      <scope>provided</scope> 
     </dependency> 
    </dependencies> 
</profile>