我有以下(非常)简单的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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ro.ace.ucv</groupId>
<artifactId>message_generator</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<scala.major.version>2.10</scala.major.version>
<scala.version>${scala.major.version}.5</scala.version>
<spark.version>1.6.0</spark.version>
<spark.streaming.version>1.6.0</spark.streaming.version>
<spark.sql.version>1.6.0</spark.sql.version>
<spark.version>1.6.0</spark.version>
<junit.version>4.12</junit.version>
<scalatest.version>2.1.3</scalatest.version>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.11</artifactId>
<version>0.10.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.message.generator.MessageGeneratorMain</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
以及以下(非常)简单的项目结构:
\ message_generator \ SRC \主\阶\ COM \消息\发生器\ MessageGeneratorMain.scala
运行mvn clean编译程序集时:单个
我得到一个带依赖关系的jar,但我自己的代码(3个类,包括Main类)不包含在最终的jar中。
答案 0 :(得分:1)
您必须包含Maven Scala插件才能捕获src / main / scala中的scala代码
<build>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>