版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/chancein007/article/details/77714667
笔者在自己的一个项目中用Maven进行编译管理自己的一个项目,因为是没有网络的环境的,所以笔者把Maven设置成了Offline模式,也就是直接使用本机Maven库里面的jar,而不是通过Internet从网上Maven仓库中心获取,其Maven的Setting.xml的文件设置如下:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>${user.home}/.m2/repository</localRepository>
<interactiveMode>true</interactiveMode>
<usePluginRegistry>false</usePluginRegistry>
<offline>true</offline>
</settings>
其中用到了sqljdbc4的库,
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
但是,编译的时候报了下面的错误,
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.516 s
[INFO] Finished at: 2017-08-30T05:25:11+08:00
[INFO] Final Memory: 19M/226M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project spavpoc: Could not resolve dependencie
s for project com.kronos:spavpoc:jar:0.0.1-SNAPSHOT: Cannot access central (http
s://repo.maven.apache.org/maven2) in offline mode and the artifact com.microsoft
.sqlserver:sqljdbc4:jar:4.0 has not been downloaded from it before. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyReso
lutionException
后发现其里面有一个_remote.reposiories文件,其内容如下,
#NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
#Tue Mar 21 10:55:02 CST 2017
sqljdbc4-4.0.pom>clojars-repo=
sqljdbc4-4.0.jar>clojars-repo=
所以有的时候遇到问题一定换一种思维方式,多角度的尝试和分析,往往会有意想不到的收货。