小白一只,探索了一天,懵....我可能踩到了所有的坑...
【遇到的问题】:
1.sqljdbc的jar包在哪里下载?诶,微软官网有!。。emm,怎么没有win版本?
2.终于得到jar包了,怎么百度都是什么sqljdbc4的方法?我该肿么办
3.BUILD Faild
4.在项目pom.xml中引入本地jar包错误
【填坑开始!】
前提:你已经装好了MySQL和Maven,建立了一个Maven项目
1.下载sqljdbc
https://dev.mysql.com/downloads/connector/j/
2.将sqljdbc引入到maven中
mvn install:install-file -Dfile=D:\mysql-connector-java-8.0.19.jar -DgroupId=com.bingo -DartifactId=sqljdbc -Dversion=8.0.19 -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true
主要是 -Dfile 选项,对应你 jar包绝对地址
坐标(-DgroupId,-DartifactId,-Dversion )自己设置
之后正常应该是BUILD SUCCESS
踩坑:结果返回BUILD FAILURE了
解决:
找到你的Maven安装路径 conf-->setting.xml 打开 ,找到< mirrors>部分,添加镜像
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
| -->
<!-- 阿里云仓库 -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
<!-- 中央仓库1 -->
<mirror>
<id>repo1</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo1.maven.org/maven2/</url>
</mirror>
<!-- 中央仓库2 -->
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
</mirrors>
重新执行上面那条 mvn install命令:BUILD SUCCESS!
于是你在本地仓库中就可以看到sqljdbc了:
3.在项目pom.xml中引入本地jar包
接下来如下图所示在pom.xml中添加< dependcy>就行了,啊可是我怎么错误了!
好吧,,低级错误,忘了设置本地仓库了,修改后就木的问题了~
用 IDEA输入 < dependency>时,自动生成的格式里没有version,记得也要加哦~
<dependencies>
<dependency>
<groupId>com.bingo</groupId>
<artifactId>sqljdbc</artifactId>
<version>8.0.19</version>
</dependency>
</dependencies>
可还行?如果对你有用给个赞好不好嘻