缺少工件 com.microsoft.sqlserver:sqljdbc4:jar:4.0

2021-12-02 00:00:00 spring sql-server maven pom.xml

我正在尝试在我的 POM.xml 文件中添加 MS SQL 驱动程序依赖项,以下是依赖项.

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>

但我得到这个例外

缺少工件 com.microsoft.sqlserver:sqljdbc4:jar:4.0

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

我真的不明白这个问题.

I really don't understand the issue.

推荐答案

UPDATE

微软现在在 maven central 中提供了这个工件.有关详细信息,请参阅 @nirmal 的回答:https://stackoverflow.com/a/41149866/1570834

Microsoft now provide this artifact in maven central. See @nirmal's answer for further details: https://stackoverflow.com/a/41149866/1570834

原答案

问题是Maven在任何配置的Maven 存储库.

The issue is that Maven can't find this artifact in any of the configured maven repositories.

不幸的是,Microsoft 没有通过任何 Maven 存储库提供此工件.您需要从 Microsoft 网站下载 jar,然后手动将其安装到本地 Maven 存储库中.

Unfortunately Microsoft doesn't make this artifact available via any maven repository. You need to download the jar from the Microsoft website, and then manually install it into your local maven repository.

您可以使用以下 Maven 命令执行此操作:

You can do this with the following maven command:

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

然后下次在 POM 上运行 maven 时,它会找到工件.

Then next time you run maven on your POM it will find the artifact.

相关文章