1.官网下载 maven 压缩包,【download】->【解压压缩包到自定义路径】
2.在conf目录中的 settings.xml文件下,修改默认的本地仓库存储路径
Maven会将下载的类库(jar包)放置在该目录下【最好修改,默认是存在C盘,来减轻C盘压力】
//我的路径:
<localRepository>D:\develop tools\apache-maven-3.6.1\m2\repository</localRepository>
3.在 IDEA 中配置 maven
4. 在IDEA中创建 maven 工程
【file】-》【new】-》【projects】-》【maven】-》【指定 SDK】
【next】-》【定义项目组、名称、版本号】-》【next】-》【finish】
创建成功:
5.想要在创建好的maven中创建 Scala类
第一种方式: 使用传统方式引入 scala 包【添加你已安装好的 Scala SDK】
第二种方式:
1)通过修改项目中的 pom.xml 文件 加载 scala包的依赖
登陆 maven 仓库 ,maven仓库地址:https://mvnrepository.com/
搜索scala library,找到你所需要的 scala 版本的 jar 包
2)向 pom.xml 文件中添加,以下代码:(添加完毕后就会下载相关的 jar 包到你自定义的仓库中)
<dependencies>
<!-- https://mvnrepository.com/artifact/org.scala-lang/scala-library -->
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.11.8</version>
</dependency>
</dependencies>
3)然后使用同样的方法将其他的包也都加载进来(已经加载了scala-library.jar)
创建scala类,【file】-》 【new】-》【scala.class】-》 【定义类名称】