Search code examples
sql-serverspringmavenpom.xml

Missing artifact com.microsoft.sqlserver:sqljdbc4:jar:4.0


I am trying to add MS SQL driver dependency in my POM.xml file and the following is the dependency.

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

but I get this exception

Missing artifact com.microsoft.sqlserver:sqljdbc4:jar:4.0

I really don't understand the issue.


Solution

  • For the old JDBC jars artifacts:

    To, [install] 3rd party JARs to [local] repo:

    # `mvn install:install-file`    to install  a custom file `install-file` [artifact] into the local repo
    # For more info about (maven-deploy-plugin) parameters:
    # https://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html
    # https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
    
    # [install > local repo] 
    # Example: com.microsoft.sqlserver:sqljdbc4:pom:3.0
    groupId=com.microsoft.sqlserver
    artifactId=sqljdbc4
    version=3.0
    packaging=jar
    file=/...path_to_jar.../sqljdbc4-3.0.jar
    pomFile=/...path_to_pom.../sqljdbc4-3.0.pom
    localRepositoryPath=/Users/~/.m2/repository
    
    
    mvn install:install-file \
        -DgroupId=$groupId \
        -DartifactId=$artifactId \
        -Dversion=$version \
        -Dpackaging=$packaging \
        -Dfile=$file \
        -DpomFile=$pomFile \
        -DlocalRepositoryPath=$localRepositoryPath
    

    To, [deploy] 3rd party JARs to [remote] repo:

    # `mvn deploy:deploy-file`      to deploy   a custom file `deploy-file` [artifact] to the remote repo
    # For more info about (maven-install-plugin) parameters:
    # https://maven.apache.org/plugins/maven-install-plugin/install-file-mojo.html
    # https://maven.apache.org/guides/mini/guide-3rd-party-jars-remote.html
    
    # [deploy > remote repo] 
    # Example: com.microsoft.sqlserver:sqljdbc4:pom:3.0
    groupId=com.microsoft.sqlserver
    artifactId=sqljdbc4
    version=3.0
    packaging=jar
    file=/...path_to_jar.../sqljdbc4-3.0.jar
    pomFile=/...path_to_pom.../sqljdbc4-3.0.pom
    createChecksum=true
    repositoryId=your_company-3rdparty-repo
    url=https://nexus.your_company.com/content/repositories/thirdparty
    
    mvn deploy:deploy-file \
        -DgroupId=$groupId \
        -DartifactId=$artifactId \
        -Dversion=$version \
        -Dpackaging=$packaging \
        -Dfile=$file \
        -DpomFile=$pomFile \
        -DcreateChecksum=$createChecksum \
        -DrepositoryId=$repositoryId \
        -Durl=$url