Scala和Java在默认的Eclipse中使用Maven
是否可以使用默认的Eclipse(用于Java EE开发人员的Eclipse IDE或用于Java开发人员的Eclipse IDE)来访问java类中的scala源代码?
在Scala中访问Java代码并且反过来使用Scala-IDE,但在默认的eclipse中不存在问题。 我可以使用下面的pom.xml来编译源代码并执行它。 我的源文件夹结构是src / main / java,src / main / scala,src / test / scala和src / test / java。 这甚至可能或者我需要ScalaIDE? 当我下载eclipse的ScalaIDE-Plugin并将scala自然添加到它正在工作的项目中时。
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.11.7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
net.alchim31.maven
</groupId>
<artifactId>
scala-maven-plugin
</artifactId>
<versionRange>
[3.2.1,)
</versionRange>
<goals>
<goal>compile</goal>
<goal>add-source</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<!-- <execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>-->
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgument>-proc:none</compilerArgument>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>test.JavaMain</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
是的,您是对的,我们不需要SCALA IDE另外,我们可以使用ECLIPSE IDE Itself来完成。
http://davidb.github.io/scala-maven-plugin/example_java.html
这个问题在这之前被问过
使用maven多模块/简单项目确保您在您的pom(=> classpath)中使用相同的scala库.jar版本ur eclipse / plugins / directory
我希望能帮助你。
链接地址: http://www.djcxy.com/p/66617.html上一篇: Scala and Java with Maven in default eclipse
下一篇: How to use just one scala library for maven/eclipse/scala