Maven构建-无法解决依赖关系

疯狂的D

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

在看到问题后,我Dfile=sqljdbc4.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar在定义了pom.xml的项目目录中手动执行了问题,结果以BUILD SUCCESS的形式出现后,按如下所述定义了一个pom.xml(部分定义)的maven项目但是,当我运行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)

参考:
我确实引用了这篇文章,但无法解决问题。

疯狂的D

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

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章