Maven Build - 无法解决依赖关系

时间:2017-02-16 02:27:06

标签: eclipse maven build maven-plugin sqljdbc

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

我有一个maven项目pom.xml(部分)定义如下所述,在看到问题后我在项目目录中手动执行Dfile=sqljdbc4.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar,其中定义了pom.xml,结果为BUILD SUCCESS 。但是,当我运行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帖子,但无法解决问题。

1 个答案:

答案 0 :(得分:0)

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

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