maven手动添加sqlserver驱动包

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


C:\apache-maven-3.2.5\bin\mvn install:install-file -Dfile=sqljdbc41.jar -Dpackaging=jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.1



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.1

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

[html] view plaincopy

<dependency>  

            <groupId>com.microsoft.sqlserver</groupId>  

            <artifactId>sqljdbc4</artifactId>  

            <version>4.2</version>  

        </dependency>  


猜你喜欢

转载自my.oschina.net/u/2438634/blog/541165