简体   繁体   English

如何从命令行在类路径中指定mysql jar?

[英]How do I specify the mysql jar in the classpath from the command line?

I am trying to run the mybatis tool from command line, and I have already specified the mysql path, but it still told me com.mysql.jdbc.Driver not found! 我正在尝试从命令行运行mybatis工具,并且我已经指定了mysql路径,但是它仍然告诉我com.mysql.jdbc.Driver找不到!

"Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver"

java -cp ./:./mysql-connector-java-5.1.14.jar -jar ./mybatis-generator-core-1.3.2.jar -configfile xmlconfig.xml

Using -jar will actually override the -cp . 使用-jar实际上将覆盖-cp So if you use the -jar make sure you have a manifest that includes all the locations of your needed mysql jars. 因此,如果使用-jar确保您有一个清单,其中包含所需mysql jar的所有位置。

Alternatively use just the -cp and specify the package and class name of your Main class. 或者,仅使用-cp并指定Main类的包和类名称。

Something like. 就像是。

java -cp ./:./mysql-connector-java-5.1.14.jar:./mybatis-generator-core-1.3.2.jar to.my.main.MainClass -configfile xmlconfig.xm

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

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