简体   繁体   English

执行Maven launch4j .exe时无反应

[英]Nothing happen when execute Maven launch4j .exe

launch4j to an exe file. 将launch4j转换为一个exe文件。 Here is my pom.xml: 这是我的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>com.mycompany</groupId>
    <artifactId>InsertMySQL</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.45</version>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.4.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.mycompany.insertmysql.insert</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.akathist.maven.plugins.launch4j</groupId>
                <artifactId>launch4j-maven-plugin</artifactId>
                <version>1.5.2</version>
                <executions>
                    <execution>
                        <id>l4j-gui</id>
                        <phase>package</phase>
                        <goals>
                            <goal>launch4j</goal>
                        </goals>
                        <configuration>
                            <headerType>gui</headerType>
                            <outfile>target/Project.exe</outfile>
                            <jar>target/InsertMySQL-1.0-SNAPSHOT.jar</jar>
                            <!-- if <dontWrapJar>true</dontWrapJar> change to this conf <jar>${project.artifactId}-${project.version}.jar</jar> -->
                            <dontWrapJar>false</dontWrapJar>
                            <errTitle>Error in launch4j plugin</errTitle>
                            <classPath>
                                <mainClass>com.mycompany.insertmysql.insert</mainClass>
                            </classPath>

                            <jre>
                                <minVersion>1.7.0</minVersion>
                                <maxVersion>1.9.0</maxVersion>
                                <initialHeapSize>512</initialHeapSize>
                                <maxHeapSize>1024</maxHeapSize>
                            </jre>
                            <versionInfo>
                                <fileVersion>1.0.0.0</fileVersion>
                                <txtFileVersion>1.0.0.0</txtFileVersion>
                                <fileDescription>des</fileDescription>
                                <copyright>Copyright (c) 2014 </copyright>
                                <companyName>comp</companyName>
                                <productVersion>3.0.0.0</productVersion>
                                <txtProductVersion>${project.version}</txtProductVersion>
                                <productName>Project</productName>
                                <internalName>Project</internalName>
                                <originalFilename>Project.exe</originalFilename>
                            </versionInfo>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            </plugins>
  </build>
</project>

above is my POM.xml 以上是我的POM.xml

Question
when double click on project.exe , nothing is executed.nothing is appear.nothing happen after execute the project.exe 双击project.exe时,不执行任何操作。不显示任何内容。执行project.exe之后不进行任何操作
anything wrong at this code?? 这段代码有什么问题吗? what i have missed? 我错过了什么? still need to install anything or what? 仍然需要安装任何东西或什么? is yes, please step by step guide me, thx =) 是的,请逐步指导我,thx =)

在此处输入图片说明

UPDATE 更新
after i had run the cmd java -cp C:\\Users\\chiny\\Desktop\\InsertMySQL\\target\\InsertMySQL-1.0-SNAPSHOT.jar com.mycompany.insertmysql.insert to solve java.lang.ClassNotFoundException: com.mysql.jdbc.Driver 在我运行cmd java -cp C:\\Users\\chiny\\Desktop\\InsertMySQL\\target\\InsertMySQL-1.0-SNAPSHOT.jar com.mycompany.insertmysql.insert解决java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

so, i had searched the solution, just mention to add the dependency, as you can see, my pom.xml is attached with dependency mysql connector already. 因此,我已经搜索了解决方案,只是提到添加依赖项,如您所见,我的pom.xml已经附加了依赖项mysql连接器。 i have no idea how to solve it 我不知道如何解决

UPDATE 2 更新2

在此处输入图片说明

how about i get this error? 我如何得到这个错误? what is this? 这是什么?

ALL THE PROBLEM IS the CLASSPATH, java can't find the mysql-connector-java.jar path. 所有的问题都是CLASSPATH,java找不到mysql-connector-java.jar路径。 how to solve it? 怎么解决呢?

but when im runing with java -cp .;C:\\Users\\chiny\\.m2\\repository\\mysql\\mysql-connector-java\\5.1.45\\mysql-connector-java-5.1.45.jar;C:\\Users\\chiny\\Desktop\\InsertMySQL\\target\\InsertMySQL-1.0-SNAPSHOT.jar com.mycompany.insertmysql.insert with mysql-connector-java-5.1.45.jar then the project.exe able to run..how to set the nysql connector classpath in programmatically ? 但是当我使用java -cp .;C:\\Users\\chiny\\.m2\\repository\\mysql\\mysql-connector-java\\5.1.45\\mysql-connector-java-5.1.45.jar;C:\\Users\\chiny\\Desktop\\InsertMySQL\\target\\InsertMySQL-1.0-SNAPSHOT.jar com.mycompany.insertmysql.insert运行时java -cp .;C:\\Users\\chiny\\.m2\\repository\\mysql\\mysql-connector-java\\5.1.45\\mysql-connector-java-5.1.45.jar;C:\\Users\\chiny\\Desktop\\InsertMySQL\\target\\InsertMySQL-1.0-SNAPSHOT.jar com.mycompany.insertmysql.insertmysql-connector-java-5.1.45.jar然后project.exe能够运行..如何设置nysql连接器类路径以编程方式?

You are creating a shade jar file to include all needed dependencies, but in the configuration of the launch4j plugin you are referencing the unshaded jar file. 您正在创建一个包含所有必需依赖项的阴影jar文件,但是在launch4j插件的配置中,您引用的是未着色的jar文件。 Update the plugin configuration to use the correct jar: 更新插件配置以使用正确的jar:

<jar>target/InsertMySQL-1.0-SNAPSHOT-shaded.jar</jar>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM