Sql Sever 2008 jar Maven pom.xml dependency

来源:互联网 发布:免费淘宝客推广软件 编辑:程序博客网 时间:2024/05/22 03:12

When I add sqlserver04.jar into my maven project, it's a little bit different others. For other jars, I directly add dependency into pom.xml. For sqlserver.jar, the dependency works on others' projects, but not mine. It always give me an error about missing artifact. Here is my solution:

1) download latest jar Microsoft download center. I download *.exe file.

2) Run the exe file and unzip it.

3) Open a command prompt and switch into the directory whre the jar file is located

4) Execute the comand

mvn install:install-file -Dfile=sqljdbc4.jar -Dpackaging=jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0

5) When you see Build Success, You can find the jar in your maven repository. Mine is located here:

C:\Users\****\.m2\repository\com\microsoft\sqlserver\sqljdbc4\4.0

6) Now you're ready to add the dependency to pom.xml

<dependency><groupId>com.microsoft.sqlserver</groupId><artifactId>sqljdbc4</artifactId><version>4.0</version></dependency>