1、创建maven
File-> New -> Maven Project
-> 勾选
Create a simple Project
Use default Workspace location
-> 配置
Group Id: com.yunbee
Artifact Id : MaxCompute
version: 0.0.0-SNAPSHOT
Packaging: jar
-> Finish
- 本配maven的JDK
1)选中maxcompute项目,右键选属性
2)点"Java Build Path"
3) 选中自带的JDK->Remove
4) Add Library
5) JRE System Library
6) Alternate JRE
7) Installed JREs
8) Add
9) Standard VM
10) JRE home
3.配置pom.xml
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<groupId>com.aliyun.odps</groupId>
<artifactId>odps-sdk-mapred</artifactId>
<version>0.37.10-public</version>
<groupId>com.aliyun.odps</groupId>
<artifactId>odps-sdk-graph</artifactId>
<version>0.37.10-public</version>
<dependency>
<mainClass>graph.SSSP</mainClass>
4.编写代码
如果代码写在别的项目中已写好,那么拷贝到maven下面:
1)先在原项目目录中找到src/package:graph(右键)->copy
2) 在maven的maxcoumpute项目上找到src/main/java(右键)->paste
编写代码:
点maxcompute->右键->new -> other -> ODPS Project
5.运行测试
run -> run configuations -> ODPS Mapreduce(双击) -> main class (自动生成:graph.SSSP)
->ODPS config (yunbee)->Arguments -> apply -> run
传参数:1 sssp_in sssp_out
3 sssp_in sssp_out
5 sssp_in sssp_out
6.编译生成jar包
点maxcompute->右键 -> Run AS -> 3.Maven build
#Goal:clean package -DskipTests
7.在目录下找到jar,压解看下文件是否正常
D:\eclipse\eclipse-workspace\maxcompute\target
maxcompute-0.0.1-SNAPSHOT.jar