This artifact is not loaded in the online Maven repositories.
The solution is to download the microsoft website and manually add it to your local Maven repository with the command:
mvn install:install-file -Dfile=sqljdbc4.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar
Source: Missing Artifact com.microsoft.sqlserver:sqljdbc4:jar:4.0
If you use Maven through the Eclipse plugin, you cannot use the command line, and you must use the Eclipse interface itself to install the library in your local repository. As per @Brunocésar’s tip in the comments, do the following:
Right-click on the project name, go to "Run As > Run Configurations..."
In the window that opens, right-click on "Maven Build" then select "New".
Fill in the "Goals" field with the command:
install:install-file -Dfile=D:\sqljdbc4.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar
In the "-Dfile=" field enter the full file path .jar
.
When running the command, if all goes well you will see the message "BUILD SUCCESS":
And pom.xml will normally accept the dependency sqljdbc4
, and will no longer show the error:
Is this command at the same prompt or elsewhere? I have to be inside the directory that is the . sql server jar?
– DiegoAugusto
It can be at the same prompt, you have to have set the variable paths correctly. It has to be in the same folder as . jar, but that folder could be any one.
– Math
I don’t think I have Maven configured in the environment variables. I will give a search to configure it
– DiegoAugusto
Here you teach how to configure: http://www.mkyong.com/maven/how-to-install-maven-in-windows/
– Math
The problem is I don’t know where my Maven folder is because I downloaded it from Eclipse kk
– DiegoAugusto
Good doubt. I’ll look here too.
– Math
@Techies you can run by Maven Embedded eclipse also if you do not want to install it. Just go to
Run Configurations > Maven Build
, right click on,New
and inGoals
include this, as @Math said:install:install-file -Dfile=D:\sqljdbc4.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar
. Put a full path by guarantee =)– Bruno César
Goals does not appear here
– DiegoAugusto
I installed Maven again and used the command and it worked, thanks
– DiegoAugusto
@Techies just did a test with Maven from Eclipse and I was able to do it according to Bruno César’s information. Actually when you install the Maven plugin there is no mvn.exe anywhere, you have to do it through the Eclipse interface. But since you already solved your problem, then blz :)
– Math
All right, I got it here too both ways. Thanks for the help
– DiegoAugusto
@Math, I believe that answer is dated: https://mvnrepository.com/artifact/com.microsoft.sqlserver/sqljdbc4 I just tested it on my machine and it worked
– Jefferson Quesado
@Jeffersonquesado verdade, now it can be done in an easy way, I will edit the answer to be generic for cases similar to this
– Math
@Jeffersonquesado I did not forget no, I just missed to stop to create a better example, have to give a good modified answer so I have to stop to do just this, I’ll see if I do tomorrow
– Math