zouzg / mybatis-generator-gui

mybatis-generator界面工具,让你生成代码更简单更快捷
6.68k stars 2.53k forks source link

增加打包为jar直接双击运行,但是报连接失败,空针异常?求进来看 #169

Closed sixtool closed 6 years ago

sixtool commented 6 years ago

增加pom.xml打包jar插件可以双击运行的。但是报连接数据库失败是什么原因。 `

maven-assembly-plugin
            <version>3.0.0</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.zzg.mybatis.generator.MainUI</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
`

at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389) ~[jfxrt.jar:na] at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416) [jfxrt.jar:na] at com.sun.glass.ui.View.handleMouseEvent(View.java:555) ~[jfxrt.jar:na] at com.sun.glass.ui.View.notifyMouse(View.java:937) ~[jfxrt.jar:na] [INFO] [18:42:04.393] [JavaFX Application Thread] [] com.zzg.mybatis.generator.util.DbUtil.getConnectionUrlWithSchema:115 --> getConnectionUrlWithSchema, connection url: jdbc:mysql://127.0.0.1:3306/radar?useUnicode=true&useSSL=false&characterEncoding=utf8 [ERROR] [18:42:04.395] [JavaFX Application Thread] [] com.zzg.mybatis.generator.controller.DbConnectionController.testConnection:72 --> null java.lang.NullPointerException: null at com.zzg.mybatis.generator.util.DbUtil.getConnection(DbUtil.java:48) ~[mybatis-generator-gui-0.8.4-jar-with-dependencies.jar:na] at com.zzg.mybatis.generator.controller.DbConnectionController.testConnection(DbConnectionController.java:69) ~[mybatis-generator-gui-0.8.4-jar-with-dependencies.jar:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144] at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71) [na:1.8.0_144] at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) ~[na:na] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]

sixtool commented 6 years ago

原因是找不到 jdbc数据库驱动包导致的,打包成一个Jar运行是,需要指定数据库驱动路径