定制小程序开发idea配置scala-sdk

定制小程序开发需要先下载的插件并重启idea

点击File->Settings

 新建一个spark-demo的maven项目

windows下在cmd定制小程序开发中查看自己scala版本(我windows定制小程序开发下已经安装好了scala)

定制小程序开发我的是社区版的所以需要在官网()下载Scala-SDK包并解压。如果是企业版的可以参考博客:

(或许有用或许没用,看看吧)

 

然后点击ok

 

 发现没有scala这个选项,只有一个Groovy一个选项,(这个图是我解决后的图,之前的图忘了截了,凑活看吧)。

解决办法参考博客:

首先File->Project Structure,选择Modules,

 选中,点击删除

 重新add frameworks support添加,就有了scala选项

选中,点击ok

 该目录下出现了scala-sdk说明添加成功

记得修改maven仓库为本地镜像

在main⽂件夹中建⽴⼀个名为 scala 的⽂件夹,并右键点击 scala ⽂件夹,选择 Make Directory as,然后选择Sources Root ,
这⾥主要意思是将 scala ⽂件夹标记为⼀个源⽂件的根⽬录,然后在其内的所有代码中的 package ,其路径就从这个根⽬录下开始算起。

 

在已经标记好为源⽂件根⽬录的 scala ⽂件夹 上,右键选择 New,然后选择 Scala Class,随后设置好程序的名称,并且记得将其设 置为⼀个 Object(类似于Java中含有静态成员的静态类),正常的话,将会打开这个 Object 代码界⾯,并且可以看到IntelliJ IDEA⾃动添加
了⼀些最基本的信息;

 

在创建的 Object 中输⼊如下语句:
def main(args: Array[String]):Unit = {println( "Hello World!" )}

 

点击左上角的run

静待程序的编译和运⾏,然后在下⽅⾃动打开的窗⼝中,就可以看到Hello World!

 

 导入spark依赖pom.xml,将下述代码替换掉原来的pom.xml文件内容

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5. <modelVersion>4.0.0</modelVersion>
  6. <groupId>cn.hgu.spark</groupId>
  7. <artifactId>demo</artifactId>
  8. <version>1.0-SNAPSHOT</version>
  9. <properties>
  10. <maven.compiler.source>1.8</maven.compiler.source>
  11. <maven.compiler.target>1.8</maven.compiler.target>
  12. <scala.version>2.11.8</scala.version>
  13. <spark.version>2.2.3</spark.version>
  14. <hadoop.version>2.7.5</hadoop.version>
  15. <encoding>UTF-8</encoding>
  16. </properties>
  17. <dependencies>
  18. <!-- 导入scala的依赖 -->
  19. <dependency>
  20. <groupId>org.scala-lang</groupId>
  21. <artifactId>scala-library</artifactId>
  22. <version>2.11.8</version>
  23. </dependency>
  24. <!-- 导入spark的依赖 -->
  25. <dependency>
  26. <groupId>org.apache.spark</groupId>
  27. <artifactId>spark-core_2.11</artifactId>
  28. <version>${spark.version}</version>
  29. </dependency>
  30. <dependency>
  31. <groupId>org.apache.spark</groupId>
  32. <artifactId>spark-sql_2.11</artifactId>
  33. <version>${spark.version}</version>
  34. </dependency>
  35. <!-- 指定hadoop-client API的版本 -->
  36. <dependency>
  37. <groupId>org.apache.hadoop</groupId>
  38. <artifactId>hadoop-client</artifactId>
  39. <version>${hadoop.version}</version>
  40. </dependency>
  41. <dependency>
  42. <groupId>junit</groupId>
  43. <artifactId>junit</artifactId>
  44. <version>4.10</version>
  45. <scope>provided</scope>
  46. </dependency>
  47. <dependency>
  48. <groupId>mysql</groupId>
  49. <artifactId>mysql-connector-java</artifactId>
  50. <version>5.1.47</version>
  51. </dependency>
  52. </dependencies>
  53. <build>
  54. <pluginManagement>
  55. <plugins>
  56. <!-- 编译scala的插件 -->
  57. <plugin>
  58. <groupId>net.alchim31.maven</groupId>
  59. <artifactId>scala-maven-plugin</artifactId>
  60. <version>3.2.2</version>
  61. </plugin>
  62. <!-- 编译java的插件 -->
  63. <plugin>
  64. <groupId>org.apache.maven.plugins</groupId>
  65. <artifactId>maven-compiler-plugin</artifactId>
  66. <version>3.5.1</version>
  67. </plugin>
  68. </plugins>
  69. </pluginManagement>
  70. <plugins>
  71. <plugin>
  72. <groupId>net.alchim31.maven</groupId>
  73. <artifactId>scala-maven-plugin</artifactId>
  74. <executions>
  75. <execution>
  76. <id>scala-compile-first</id>
  77. <phase>process-resources</phase>
  78. <goals>
  79. <goal>add-source</goal>
  80. <goal>compile</goal>
  81. </goals>
  82. </execution>
  83. <execution>
  84. <id>scala-test-compile</id>
  85. <phase>process-test-resources</phase>
  86. <goals>
  87. <goal>testCompile</goal>
  88. </goals>
  89. </execution>
  90. </executions>
  91. </plugin>
  92. <plugin>
  93. <groupId>org.apache.maven.plugins</groupId>
  94. <artifactId>maven-compiler-plugin</artifactId>
  95. <executions>
  96. <execution>
  97. <phase>compile</phase>
  98. <goals>
  99. <goal>compile</goal>
  100. </goals>
  101. </execution>
  102. </executions>
  103. </plugin>
  104. <!-- 打jar插件 -->
  105. <plugin>
  106. <groupId>org.apache.maven.plugins</groupId>
  107. <artifactId>maven-shade-plugin</artifactId>
  108. <version>2.4.3</version>
  109. <executions>
  110. <execution>
  111. <phase>package</phase>
  112. <goals>
  113. <goal>shade</goal>
  114. </goals>
  115. <configuration>
  116. <filters>
  117. <filter>
  118. <artifact>*:*</artifact>
  119. <excludes>
  120. <exclude>META-INF/*.SF</exclude>
  121. <exclude>META-INF/*.DSA</exclude>
  122. <exclude>META-INF/*.RSA</exclude>
  123. </excludes>
  124. </filter>
  125. </filters>
  126. </configuration>
  127. </execution>
  128. </executions>
  129. </plugin>
  130. </plugins>
  131. </build>
  132. </project>

 需要稍微等几分钟才能下载完相应的版本依赖。

网站建设定制开发 软件系统开发定制 定制软件开发 软件开发定制 定制app开发 app开发定制 app开发定制公司 电商商城定制开发 定制小程序开发 定制开发小程序 客户管理系统开发定制 定制网站 定制开发 crm开发定制 开发公司 小程序开发定制 定制软件 收款定制开发 企业网站定制开发 定制化开发 android系统定制开发 定制小程序开发费用 定制设计 专注app软件定制开发 软件开发定制定制 知名网站建设定制 软件定制开发供应商 应用系统定制开发 软件系统定制开发 企业管理系统定制开发 系统定制开发