Using eclipse and maven 2, how to get dependancy for sqljdbc4?

我的未来我决定 提交于 2019-12-10 21:58:00

问题


I am using eclipse with the maven 2 plugin.

I want to add the dependency for sqljdbc4, how can I do that?

Can't seem to find it via the 'add dependency' option in eclipse?


回答1:


If sqljdbc4 is the Microsoft SQL Server JDBC Driver, then you will very likely not find it in any "public" repository because of licensing issues.

So you'll have to download it, unpack it and install it manually with either mvn install:install-file (or mvn deploy:deploy-file if you have a repository manager).

Another option would be to use jTDS (which is open source and available in maven central repository) if your database engine is supported.




回答2:


Suppose your SQL server jar is sqljar-1.4.2.jar

Use the follwing command in maven cmd

mvn install:install-file -DgroupId=com.org.sqlserver -DartifactId=sqljar -Dversion=1.4.2 -Dpackaging=jar -Dfile="C:\sqljar-1.4.2.jar"

will install the sqljar in your local maven repository .

and then include follwing dependency in your pom.xml

<dependency>
    <groupId>com.org.sqlserver</groupId>
    <artifactId>sqljar</artifactId>
    <version>1.4.2</version>
</dependency>

your can change the group id or artifact id or version depending on your wish




回答3:


Use the maven-eclipse-plugin to generate your .classpath and .project and all will be well.

Failing that, you have to find the jar in your ~/.m2/repository and add it as an external library.



来源:https://stackoverflow.com/questions/2444669/using-eclipse-and-maven-2-how-to-get-dependancy-for-sqljdbc4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!