下面Maven的pom文件
-
-
<maven.compiler.source>1.8
</maven.compiler.source>
-
<maven.compiler.target>1.8
</maven.compiler.target>
-
<encoding>UTF-8
</encoding>
-
<scala.version>2.11.8
</scala.version>
-
<scala.compat.version>2.11
</scala.compat.version>
-
-
-
-
-
-
<groupId>org.scala-lang
</groupId>
-
<artifactId>scala-library
</artifactId>
-
<version>${scala.version}
</version>
-
-
-
-
-
-
<sourceDirectory>src/main/scala
</sourceDirectory>
-
<testSourceDirectory>src/test/scala
</testSourceDirectory>
-
-
-
-
<groupId>net.alchim31.maven
</groupId>
-
<artifactId>scala-maven-plugin
</artifactId>
-
<version>3.2.2
</version>
-
-
-
-
-
<goal>testCompile
</goal>
-
-
-
-
<!--<arg>-make:transitive</arg>-->
<!--scala2.11 netbean不支持这个参数-->
-
<arg>-dependencyfile
</arg>
-
<arg>${project.build.directory}/.scala_dependencies
</arg>
-
-
-
-
-
-
-
-
-
<groupId>org.apache.maven.plugins
</groupId>
-
<artifactId>maven-shade-plugin
</artifactId>
-
<version>2.4.3
</version>
-
-
-
-
-
-
-
-
-
-
<artifact>*:*
</artifact>
-
-
<exclude>META-INF/*.SF
</exclude>
-
<exclude>META-INF/*.DSA
</exclude>
-
<exclude>META-INF/*.RSA
</exclude>
-
-
-
-
-
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
-
<resource>reference.conf
</resource>
-
-
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
-
<mainClass>cn.itcast.rpc.Master
</mainClass>
<!--main方法-->
-
-
-
-
-
-
-
-
上面是使用Scala2.11的版本,注意scala2.11 netbean不支持这个参数-make:transitive这个参数,所以必须得注释掉
下面是简单的测试:
![](https://img-blog.csdn.net/20161208103554428?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvamlhbmdwZW5nNTk=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
使用Maven进行jar依赖打包,之前使用Idea的artifacts进行打包,但是导出的jar有可能因为缺少某些信息而无法直接运行,但是使用maven自动的pakage便没有这个问题,而且jar包的大小明显小于artifacts的jar包大小,下面是使用方法
![](https://img-blog.csdn.net/20161208103951976?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvamlhbmdwZW5nNTk=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
下载完相关的依赖后,会在target的目录下生成下项目的jar包