【问题标题】:Maven Build - Couldn't resolve dependenciesMaven Build - 无法解决依赖关系
【发布时间】:2017-07-04 23:02:39
【问题描述】:

操作系统:OSX Yosemite
Eclipse:Kepler
问题:
1. [来自 Eclipse 运行]:缺少 maven-compiler-plugin
2. [从命令行]:找不到 com.microsoft.sqlserver:sqljdbc4:jar:2.0

我有一个 maven 项目,其中 pom.xml(部分)定义如下所述,在看到问题后,我在定义 pom.xml 的项目目录中手动执行Dfile=sqljdbc4.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar,结果是构建成功。但是,当我运行 maven build 时出现错误 [2]。当我尝试在 Eclipse 中运行时,我收到错误1

MVN:

mvn -version    
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T10:41:47-06:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec

POM.XML:

<dependency> 
    <groupId>com.microsoft.sqlserver</groupId> 
    <artifactId>sqljdbc4</artifactId> 
    <version>2.0</version>
    <scope>runtime</scope>
</dependency>

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
    <configuration>
    <compilerVersion>1.6</compilerVersion>
    <target>1.6</target>
    <source>1.6</source>
    <fork>true</fork>
    </configuration>
</plugin>

错误 1:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for XXXXXXXXXX:war:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 139, column 12
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.   

错误 2:

[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for XXXXXXX:war:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 139, column 12
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building XXXXXX 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.microsoft.sqlserver:sqljdbc4:jar:2.0 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.381 s
[INFO] Finished at: 2017-02-15T20:04:48-06:00
[INFO] Final Memory: 7M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project XXXXXX: Could not resolve dependencies for project XXXXXXXXX:war:0.0.1-SNAPSHOT: Failure to find com.microsoft.sqlserver:sqljdbc4:jar:2.0 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project XXXXXX: Could not resolve dependencies for project XXXXXXXXX:war:0.0.1-SNAPSHOT: Failure to find com.microsoft.sqlserver:sqljdbc4:jar:2.0 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:221)

参考:
我确实参考了this 的帖子,但无法解决问题。

【问题讨论】:

    标签: eclipse maven build maven-plugin sqljdbc


    【解决方案1】:

    需要在maven目录下添加sqlserver jar文件,如下所述,

    Path : /Users/xxxxx/.m2/repository/com/microsoft/sqlserver/sqljdbc4/2.0
    File: sqljdbc4-2.0.jar
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-12-14
      • 2016-03-10
      • 2020-08-27
      • 2014-09-05
      • 1970-01-01
      相关资源
      最近更新 更多