一、安装IDEA
下载IDEA安装包。
下载路径为http://www.jetbrains.com/idea/download/#section=windows(一般不要下载最新版本,在other versions里寻找需要的版本。Ultimate是企业版,需要付费; Community是社区版,不需要付费。我们下载社区版的。)
找到下载的安装包,双击运行,按照提示进行安装。
点击finish后会重启IDEA
二、IDEA配置maven
三、创建第一个scala的maven
如果导入失败,将下面的代码复制到该处并修改groupid和artifactid
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dyh.scala</groupId>
<artifactId>demo1</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.scala-lang/scala-library -->
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.12.2</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<!-- <arg>-make:transitive</arg>-->
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass></mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
修改maven项目名称的目录名直到所有的依赖没有报错(代码没有出现红色)
四、检验
如果创建项目时出现如下情况,即表示项目创建不成功
解决方法:
找到IDEA的安装目录,进入到IntelliJ IDEA Community Edition 2017.1.6\bin
我的路径是D:\Study Softwares\IDEA\IntelliJ IDEA Community Edition 2017.1.6\bin,然后在idea.exe.vmoptions 或和idea64.exe.vmoptions的末尾中加入配置-Djdk.util.zip.ensureTrailingSlash=false
然后重启IDEA就可以正常创建了。
转载:https://blog.csdn.net/qq_42800256/article/details/102490499
查看评论