zoukankan      html  css  js  c++  java
  • scala的maven项目打包后没有内容

    在建立maven项目时,遇到问题,只能对java代码的打包。

    此问题出现的原因时,在建立项目的时候,建立的时java的项目,后期进行scala的添加,但是在pom.xml中并没有出现scala代码的打包配置,导致只能进行java代码的打包。

    解决方法:

    在maven文件中,加入scala的打包配置。

    <!-- This plugin compiles Scala files -->
    <plugin>
    <groupId>net.alchim31.maven</groupId>
    <artifactId>scala-maven-plugin</artifactId>
    <version>3.2.2</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>


    pom.xml 详情如下:

    <?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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    
    <groupId>com.fyy</groupId>
    <artifactId>SparkOnHive</artifactId>
    <version>1.0-SNAPSHOT</version>
    
    <properties>
    <encoding>UTF-8</encoding>
    <scala.version>2.11.12</scala.version>
    <spark.version>2.4.0-cdh6.1.1</spark.version>
    <hive.version>2.1.1-cdh6.1.1</hive.version>
    </properties>
    
    <!--使用cdh安装包,必须加入-->
    <repositories>
    <repository>
    <id>cloudera</id>
    <url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
    </repository>
    </repositories>
    
    <!-- mysql依赖 -->
    <dependencies>
    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.38</version>
    </dependency>
    
    <!-- scala依赖 -->
    <dependency>
    <groupId>org.scala-lang</groupId>
    <artifactId>scala-library</artifactId>
    <version>${scala.version}</version>
    </dependency>
    
    <!-- spark sql依赖 -->
    <dependency>
    <groupId>org.apache.spark</groupId>
    <artifactId>spark-sql_2.11</artifactId>
    <version>${spark.version}</version>
    </dependency>
    
    <!-- spark hive依赖 -->
    <dependency>
    <groupId>org.apache.spark</groupId>
    <artifactId>spark-hive_2.11</artifactId>
    <version>${spark.version}</version>
    </dependency>
    
    <!-- spark-core依赖 -->
    <dependency>
    <groupId>org.apache.spark</groupId>
    <artifactId>spark-core_2.11</artifactId>
    <version>${spark.version}</version>
    </dependency>
    </dependencies>
    <build>
    <finalName>${project.artifactId}</finalName>
    <outputDirectory>target/classes</outputDirectory>
    <testOutputDirectory>target/test-classes</testOutputDirectory>
    <plugins>
    <!-- This plugin compiles Scala files -->
    <plugin>
    <groupId>net.alchim31.maven</groupId>
    <artifactId>scala-maven-plugin</artifactId>
    <version>3.2.2</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>
    
    <!-- This plugin compiles Java files -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.5.1</version>
    <configuration>
    <source>1.8</source>
    <target>1.8</target>
    </configuration>
    <executions>
    <execution>
    <phase>compile</phase>
    <goals>
    <goal>compile</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    </plugins>
    </build>
  • 相关阅读:
    boost库的使用介绍
    《架构实战软件架构设计的过程》
    常用开发命令
    《项目管理最佳实践案例剖析》
    From Live Writer
    希望实现的程序
    正在进行调试的Web服务器进程已由Internet信息服务(IIS)终止。可以通过在IIS中配置应用程序池Ping设置来避免这一问题。有关更多详细信息,请参见“帮助”
    请确保此代码文件中定义的类与“inherits”属性匹配
    更改IE默认源代码编辑器
    MS的.net源码地址
  • 原文地址:https://www.cnblogs.com/erlou96/p/12933424.html
Copyright © 2011-2022 走看看