idea16使用maven命令clean、编译、打包jar或者war
项目环境:idea16+jdk1.7+maven-3.3.9
项目说明:编写简单的java类,使用maven命令生成jar包,然后执行-------》"java -classpath jar所在路径 main类名称"
注意:使用idea16工具的maven命令生成的jar包可能不包含第三方依赖
1、编写pom.xml文件
- <?xml version="1.0" encoding="UTF-8"?>
- 4.0.0spark-jqz-predictcom.enn1.0-SNAPSHOTUTF-8UTF-81.7<!--add maven release-->1.71.7UTF-8mysqlmysql-connector-java5.1.24<!--junit-->junitjunit4.12<!--slf4j-->org.slf4jslf4j-log4j121.7.20<!---
- 引入本地jar
- <dependency>
- <groupId>org.apache.spark</groupId>
- <artifactId>spark-assembly_2.10</artifactId>
- <version>1.6.0-cdh5.8.0</version>
- <scope>system</scope>
- <systemPath>D:/spark-assembly-1.6.2-hadoop2.6.0.jar</systemPath>
- </dependency>
- --><!--编译java代码使用该配置-->spark-jqz-predict<!-- 编译插件 -->org.apache.maven.pluginsmaven-compiler-plugin3.11.71.7UTF-8<!-- 打包 -->maven-assembly-pluginjar-with-dependenciesmake-assemblypackagesingle<!--注意:如果是编译scala代码,则需要使用如下配置--><!--
- <build>
- <finalName>sparkEnn</finalName>
- <sourceDirectory>src/main/scala</sourceDirectory>
- <testSourceDirectory>src/test/scala</testSourceDirectory>
- <plugins>
- <plugin>
- <groupId>org.scala-tools</groupId>
- <artifactId>maven-scala-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>compile</goal>
- <goal>testCompile</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <scalaVersion>${scala.version}</scalaVersion>
- <args>
- <arg>-target:jvm-1.7</arg>
- </args>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-eclipse-plugin</artifactId>
- <configuration>
- <downloadSources>true</downloadSources>
- <buildcommands>
- <buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand>
- </buildcommands>
- <additionalProjectnatures>
- <projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature>
- </additionalProjectnatures>
- <classpathContainers>
- <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
- <classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
- </classpathContainers>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptorRefs>
- <descriptorRef>jar-with-dependencies</descriptorRef>
- </descriptorRefs>
- <archive>
- <manifest>
- <mainClass></mainClass>
- </manifest>
- </archive>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.scala-tools</groupId>
- <artifactId>maven-scala-plugin</artifactId>
- <configuration>
- <scalaVersion>${scala.version}</scalaVersion>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
- -->