Я могу сгенерировать exe-файл с помощью плагина maven, и все в порядке.
Но когда я добавляю зависимость spark-mllib
, я перезапускаю maven clean maven install
, и exe, сгенерированный maven, не запускается.
Java-код
public class App
{
public static void main(String[] args) {
Hello ex = new Hello();
ex.setVisible(true);
}
}
public class Hello extends JFrame {
public Hello() {
setTitle("Simple example");
setSize(300, 200);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
Maven Pom.xml
<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>a</groupId>
<artifactId>a</artifactId>
<version>0.0.1</version>
<properties>
<org.springframework.version>3.0.5.RELEASE</org.springframework.version>
<jdk.version>1.8</jdk.version>
<jodatime.version>2.5</jodatime.version>
<junit.version>4.11</junit.version>
<maven.test.skip>true</maven.test.skip>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- <maven.compiler.source>1.8.0</maven.compiler.source> <maven.compiler.target>1.8.0</maven.compiler.target> -->
</properties>
<name>a</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<configuration>
<rules>
<dependencyConvergence />
</rules>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<id>build-massTer</id>
<configuration>
<transformers>
<!-- add Main-Class to manifest file -->
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>a.a.App</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<finalName>${project.artifactId}-${project.version}</finalName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>1.7.25</version>
<executions>
<execution>
<id>MassTer Premium</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<dontWrapJar>false</dontWrapJar>
<headerType>gui</headerType>
<jar>${project.build.directory}/${project.artifactId}-${project.version}.jar</jar>
<outfile>${project.build.directory}/${project.artifactId}-${project.version}.exe</outfile>
<downloadUrl>http://java.com/download</downloadUrl>
<classPath>
<mainClass>a.a.App</mainClass>
<!-- <preCp>${project.build.directory}/${project.artifactId}-${project.version}.jar</preCp> -->
<addDependencies>true</addDependencies>
</classPath>
<icon></icon>
<jre>
<minVersion>1.6.0_1</minVersion>
<maxVersion></maxVersion>
<initialHeapPercent>10</initialHeapPercent>
<maxHeapPercent>90</maxHeapPercent>
</jre>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<versionRange>
[2.5.1,)
</versionRange>
<goals>
<goal>testCompile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<resources>
<resource>
<targetPath></targetPath>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources</directory>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/config.properties</include>
</includes>
</resource>
<resource>
<targetPath></targetPath>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources/files</directory>
<!-- <includes> <include>configuration.xml</include> </includes> <excludes>
<exclude>**/*.properties</exclude> </excludes> -->
</resource>
<resource>
<targetPath></targetPath>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources/files/pictures</directory>
</resource>
<resource>
<targetPath></targetPath>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources/files/xmlFile</directory>
</resource>
</resources>
<testResources>
</testResources>
</build>
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-mllib_2.11</artifactId>
<version>2.3.1</version>
</dependency>
<!-- <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId>
<version>${junit.version}</version> <scope>test</scope> </dependency> <dependency>
<groupId>com.joptimizer</groupId> <artifactId>joptimizer</artifactId> <version>3.5.1</version>
</dependency> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-sql_2.12</artifactId>
<version>2.4.0</version> </dependency> -->
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-mllib -->
</dependencies>
<repositories>
<repository>
<id>cloudera</id>
<url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
</repository>
</repositories>