简体   繁体   English

jTDS - 运行 Maven 构建项目时没有合适的驱动程序异常

[英]jTDS - No Suitable Driver Exception when running a Maven built project

We have a simple [spring-hibernate] application (console app) where in we have set the classpath in manifest file of the executable JAR file.我们有一个简单的 [spring-hibernate] 应用程序(控制台应用程序),其中我们在可执行 JAR 文件的清单文件中设置了类路径。 And the app connects to the database using jTDS JDBC Driver, Everything works as expected on Windows machine and JDK 1.6, but on Linux, the app is unable to find the driver, We are running the program using java -jar MainClassName. And the app connects to the database using jTDS JDBC Driver, Everything works as expected on Windows machine and JDK 1.6, but on Linux, the app is unable to find the driver, We are running the program using java -jar MainClassName.

Any suggestions why this might be happening is greatly appreciated.非常感谢任何关于为什么会发生这种情况的建议。

This issue occurred because our jdbc.url had invalid url.出现此问题是因为我们的 jdbc.url 的 url 无效。 This was because maven treats jdbc.url property as a special property and while profiling, instead of url defined in the filter.properties. This was because maven treats jdbc.url property as a special property and while profiling, instead of url defined in the filter.properties. And that is the reason "No Suitable Driver" exception.这就是“没有合适的司机”例外的原因。 The question should have been more clear.这个问题应该更清楚。

Anyways to fix that we had to rename jdbc.url properties to jdbc.url.somename.无论如何要解决这个问题,我们必须将 jdbc.url 属性重命名为 jdbc.Z572D4E42some55E6B29E121D。 This fixed our issue with maven profiling.这解决了 maven 分析的问题。 We also had a similar maven profiling issue for a property called "server.name" This filter property was also confusing maven profiling.对于名为“server.name”的属性,我们还遇到了类似的 maven 分析问题。此过滤器属性也使 maven 分析感到困惑。 We had to change the name of that property as well.我们还必须更改该属性的名称。

Thanks again Fernando.再次感谢费尔南多。

Honestly it sounds like bad CLASSPATH.老实说,这听起来像是糟糕的 CLASSPATH。 One thing I suggest to start debugging this problem is copying the jtds package to same path as your main packages/classes and see if it works.我建议开始调试此问题的一件事是将 jtds package 复制到与主包/类相同的路径,看看它是否有效。 This way you can assure the Classpath manifest is or isn't the problem.通过这种方式,您可以确保 Classpath 清单是否存在问题。 The Spring/Hibernate relies on the lib directory, so it will always be on classpath because it's main structure. Spring/Hibernate 依赖于 lib 目录,因此它将始终位于类路径中,因为它是主要结构。 Use the lib directory also to test.也可以使用 lib 目录进行测试。

Hope this guidelines will help.希望本指南会有所帮助。 Also send more information, like paths, classpath and manifest files.还发送更多信息,例如路径、类路径和清单文件。

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

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