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?
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.
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
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.
精彩评论