qingkuangs 发表于 2019-1-30 13:23:00

spark的java和scala混合工程构建记录!

  spark的java和scala混合工程构建记录!
  今天就跟这个赶上了,各种办法,各种百度。
  

  一、maven手动构建
  

  1、dos命令下,进入目录,构建一个scala模板的工程
  

  mvn archetype:generate -DarchetypeGroupId=org.scala-tools.archetypes -DarchetypeArtifactId=scala-archetype-simple -DremoteRepositories=http://scala-tools.org/repo-releases -DgroupId=com.dyq -DartifactId=KafkaSparkRedis -Dversion=1.0-SNAPSHOT
  

  

  4、新建Java的目录

  

  

结果如下所示,没有的就加上
├── pom.xml
├── src│   
   ├── main│      
   │   ├── java│         
   │   │   └── com.jhh│            
    │   │             │ ── Main.java         
    │   └── scala│         
    │         └── com│            
    │               │ ── jhh            
    │                           │── App.scala   
    └── test│      
          ├── java│      
          └── scala  

3、改造成eclipse工程:

进入工程目录,进入工程目录,进入工程目录,不要在上一层!
mvn eclipse:eclipse
我用以上2遍就成功了。
还有可以用:
mvn org.apache.maven.plugins:maven-eclipse-plugin:2.6:eclipse
  
  完成后,会出现.project和.classpath2个目录,至少根目录是这样的!

  
  4、使用eclipse导入工程
  
  修改scala的JDK
  
  5、添加管理Java的插件
  修改pom.xml文件
修改pom.xml添加一个管理java源码的pluginbuild-helper plugin,添加位置
/project/build/plugins

org.codehaus.mojo
build-helper-maven-plugin


generate-sources
add-source


src/main/java



  

  以上出现的问题就是scala版本冲突,
  DescriptionResourcePathLocationType
  specs_2.10.4-1.6.5.jar of KafkaSparkRedis build path is cross-compiled with an incompatible version of Scala (2.10.4). In case this report is mistaken, this check can be disabled in the compiler preference page.KafkaSparkRedisUnknownScala Version Problem
  以及:

  DescriptionResourcePathLocationType
  specs_2.8.0-1.6.5.jar of KafkaSparkRedis build path is cross-compiled with an incompatible version of Scala (2.8.0). In case this report is mistaken, this check can be disabled in the compiler preference page.KafkaSparkRedisUnknownScala Version Problem
  

  原因就是scala-tools是用2.8.0的scala版本编译的,而maven中央资源库里最高只有2.9版本的scala编译的,无解!
  

  




页: [1]
查看完整版本: spark的java和scala混合工程构建记录!