scala eclipse maven环境搭建

本文档详细介绍了如何搭建Scala、Eclipse和Maven的开发环境。首先,你需要从scala-ide.org下载Scala版本的Eclipse。然后,通过生成Maven项目并配置pom.xml文件来设置项目。在遇到Scala版本不兼容的问题时,需在Eclipse中选择合适的Scala编译版本。同时,文中提供了一系列Maven仓库的URL,用于解决依赖问题。确保更新Maven项目并解决所有报错。
摘要由CSDN通过智能技术生成

 

scala eclipse maven环境搭建

 

下载 scala版本eclipse

http://scala-ide.org/

 

生成maven项目

 

复制下边的pom.xml

<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.dirk</groupId>
  <artifactId>DThorMaster</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
  <properties>
    <scala.version>2.10.4</scala.version>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
    <hadoop.version>2.3.0-cdh5.1.0</hadoop.version>
	<hbase.version>0.98.1-cdh5.1.0</hbase.version>
    <encoding>UTF-8</encoding>
  </properties>
  
  <dependencies>
  
	<dependency>  
   		<groupId>jdk.tools</groupId>  
   		<artifactId>jdk.tools</artifactId>  
   		<version>1.7</version>  
   		<scope>system</scope>  
   		<systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>  
	</dependency>
     <!-- scala -->
    <dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-library</artifactId>
      <version>${scala.version}</version>
    </dependency>
      <!-- test -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    
    <dependency>
			<groupId>net.sf.json-lib</groupId>
			<artifactId>json-lib</artifactId>
			<version>2.4</version>
			<classifier>jdk15</classifier>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.11</version>
		</dependency>
		<dependency>
			<groupId>org.clojure</groupId>
			<artifactId>clojure</artifactId>
			<version>1.5.1</version>
			<scope>provided</scope>
		</dependency>
		
		<dependency>
    		<groupId>redis.clients</groupId>
    		<artifactId>jedis</artifactId>
    		<version>2.6.0</version>
    		<type>jar</type>
    		<scope>compile</scope>
		</dependency>
		 <!--
		 <dependency>
			<groupId>redis.clients</groupId>
			<artifactId>jedis</artifactId>
			<version>2.2.1</version>
		</dependency>
		-->
		<dependency>
			<groupId>org.apache.storm</groupId>
			<artifactId>storm-kafka</artifactId>
			<version>0.9.3</version>
		</dependency>
		<dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka_2.10</artifactId>
            <version>0.8.2.0</version>
            <scope>compile</scope>
			<exclusions>
				<exclusion>
			      <groupId>org.scala-lang</groupId>
			      <artifactId>scala-library</artifactId>
				</exclusion>
				<exclusion>
					<artifactId>slf4j-api</artifactId>
					<groupId>org.slf4j</groupId>
				</exclusion>
				<exclusion>
					<artifactId>zookeeper</artifactId>
					<groupId>org.apache.zookeeper</groupId>
				</exclusion>
			</exclusions>
		</dependency>
		<!--  
		<dependency>
            <groupId>com.googlecode.matrix-toolkits-java</groupId>
            <artifactId>mtj</artifactId>
            <version>1.0.1</version>
        </dependency>
        <dependency>
  			<groupId>com.emar.adx</groupId>
  			<artifactId>naive-bayes</artifactId>
  			<version>1.0.3</version>
		</dependency>
		<dependency>
		  <groupId>com.huaban</groupId>
		  <artifactId>jieba-analysis</artifactId>
		  <version>1.0.0</version>
		  <classifier>sources</classifier>
		</dependency>
		-->
		<!-- hbase -->
		<dependency>
			<groupId>org.apache.hbase</groupId>
			<artifactId>hbase-protocol</artifactId>
			<version>${hbase.version}</version>
		</dependency>
		<dependency>
		  <groupId>org.apache.hbase</groupId>
		  <artifactId>hbase-server</artifactId>
		  <version>${hbase.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.hbase</groupId>
			<artifactId>hbase-client</artifactId>
			<version>${hbase.version}</version>
		</dependency>

		<!-- hadoop -->
		<dependency>
		  <groupId>org.apache.hadoop</groupId>
		  <artifactId>hadoop-mapreduce-client-core</artifactId>
		  <version>${hadoop.version}</version>
		</dependency>
		<dependency>
		  <groupId>org.apache.hadoop</groupId>
		  <artifactId>hadoop-mapreduce-client-common</artifactId>
		  <version>${hadoop.version}</version>
		</dependency>
		<dependency>
		  <groupId>org.apache.hadoop</groupId>
		  <artifactId>hadoop-mapreduce-client-jobclient</artifactId>
		  <version>${hadoop.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.hadoop</groupId>
			<artifactId>hadoop-hdfs</artifactId>
			<version>${hadoop.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.hadoop</groupId>
			<artifactId>hadoop-common</artifactId>
			<version>${hadoop.version}</version>
		</dependency>
		
		<dependency>
			<groupId>org.apache.zookeeper</groupId>
			<artifactId>zookeeper</artifactId>
			<version>3.4.5-cdh5.1.0</version>
		</dependency>
		

		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>1.6.0</version>
			<scope>provided</scope>
		</dependency>
		
		
		<dependency>
			<groupId>org.apache.storm</groupId>
			<artifactId>storm-core</artifactId>
			<version>0.9.3</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.18</version>
		</dependency>
		<dependency>
			<groupId>commons-httpclient</groupId>
			<artifactId>commons-httpclient</artifactId>
			<version>3.0.1</version>
		</dependency>
		
		
		<dependency>
		  <groupId>org.apache.spark</groupId>
		  <artifactId>spark-core_2.10</artifactId>
		  <version>1.3.0</version>
		  <exclusions>
				<exclusion>
			      <groupId>org.scala-lang</groupId>
			      <artifactId>scala-library</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
		  <groupId>org.apache.spark</groupId>
		  <artifactId>spark-sql_2.10</artifactId>
		  <version>1.3.0</version>
		  <exclusions>
				<exclusion>
			      <groupId>org.scala-lang</groupId>
			      <artifactId>scala-library</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
  </dependencies>
  
  <build>
  

  
  	<plugins>
  		<plugin>
        <!-- see http://davidb.github.com/scala-maven-plugin -->
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-maven-plugin</artifactId>
        <version>3.1.6</version>
        <!-- 必须要,否则不能混合编译交叉引用文件 -->
        <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-jar-plugin</artifactId>
			<configuration>
				<archive>
					<manifest>
						<mainClass>com.dirk.master.DTMaster</mainClass>
						<addClasspath>true</addClasspath>
						<classpathPrefix>lib/</classpathPrefix>
					</manifest>
				</archive>
			</configuration>
		</plugin>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-dependency-plugin</artifactId>
			<executions>
				<execution>
					<id>copy</id>
					<phase>package</phase>
					<goals>
						<goal>copy-dependencies</goal>
					</goals>
					<configuration>
						<outputDirectory>
							${project.build.directory}/lib
						</outputDirectory>
					</configuration>
				</execution>
			</executions>
		</plugin>
  	
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-antrun-plugin</artifactId>
			<version>1.6</version>
			<executions>
				<execution>
					<id>compile</id>
					<phase>package</phase>
					<configuration>
						<target>
							<copy todir="target/webapp" overwrite="true">
								<fileset dir="webapp" />
							</copy>
						</target>
					</configuration>
					<goals>
						<goal>run</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
  	
  	</plugins>
  
  </build>
  
</project>

 

运行 maven->update

 

 报错:

with an incompatible version of Scala (2.10.0)

选择scala compile2.10

 

 

 

<profile>

<id>emar</id>

<repositories>

<repository>

<id>emar</id>

<url>http://dev.emaradx.com/nexus/content/groups/public/</url>

</repository>

<repository>

<id>central</id>

<url>http://repo1.maven.org/maven2/</url>

<snapshots>

<enabled>false</enabled>

</snapshots>

<releases>

<enabled>true</enabled>

</releases>

</repository>

<repository>

<id>clojars</id>

<url>https://clojars.org/repo/</url>

<snapshots>

<enabled>true</enabled>

</snapshots>

<releases>

<enabled>true</enabled>

</releases>

</repository>

<repository>

<id>scala-tools</id>

<url>http://scala-tools.org/repo-releases</url>

<snapshots>

<enabled>true</enabled>

</snapshots>

<releases>

<enabled>true</enabled>

</releases>

</repository>

<repository>

<id>conjars</id>

<url>http://conjars.org/repo/</url>

<snapshots>

<enabled>true</enabled>

</snapshots>

<releases>

<enabled>true</enabled>

</releases>

</repository>

<repository>

<id>cdh</id>

<url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>

</repository>

</repositories>

</profile>

<profile>

<id>central</id>

<repositories>

<repository>

<id>central</id>

<url>http://repo1.maven.org/maven2/</url>

<releases>

<enabled>true</enabled>

</releases>

<snapshots>

<enabled>true</enabled>

</snapshots>

</repository>

</repositories>

</profile>

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值