IDEA集成MaxCompute
IDEA集成MaxCompute
集成方式參閱:
https://help.aliyun.com/document_detail/50891.html?spm=5176.product27797.6.730.Lbsygn
開發UDF
創建測試類
在src/main/java下創建MaxCompute Java 裏麵默認有一個帶有一個參數的方法,如果我們的UDF中需要傳入多個參數,那麼我們可以重構默認方法,根據自己的需求添加參數。具體可以參考UDF項目的example示例開發測試
在我們的UDF類上右鍵,點擊RUN XXXX。進入執行配置界麵,
帶星號的這幾項為必填項
project: 你odps對應的project
table: 你odps對應的表名稱
partition: odps表的分區
columns: odps作為入參傳入的列名稱,多個用逗號隔開
配置好後,點擊apply 然後執行
- 發布 發布前,需要把剛剛的項目打成jar包,對於有自己特殊依賴的項目,打包時要將依賴打進去。將所有依賴包含進去打成一個jar需要配置一個maven 插件
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<!-- 此處指定main方法入口的class -->
<mainClass>com.cainiao.ts.udf.com.cainiao.ts.udf.RowkeyGenerater</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>assembly</goal>
</goals>
</execution>
</executions>
</plugin>
編譯打包沒問題後,在剛剛的函數類右鍵,執行deploy to server
填寫好函數名稱,就會將UDF資源上傳到服務並注冊好函數
最後更新:2017-08-31 11:33:14