我可以使用 mvn install:install-file 安装 mysql jdbc 连接器吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15561038/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can I install the mysql jdbc connector using mvn install:install-file?
提问by user2197446
I'd like to install the JDBC connector using maven.
我想使用 maven 安装 JDBC 连接器。
I have the following: mvn install:install-file -DgroupId=mysql -DartifactId=mysql-connnector-java -Dversion=5.1.6 -Dpackaging=jar -Dfile= -DgenerationPom=true
我有以下内容: mvn install:install-file -DgroupId=mysql -DartifactId=mysql-connnector-java -Dversion=5.1.6 -Dpackaging=jar -Dfile= -DgenerationPom=true
I think all I'm need is what I put on the other side of the =Dfile= ?
我想我所需要的只是放在 =Dfile= 另一边的东西?
I haven't used maven in a while either, so I'm not sure what the file switch is used for?
我也有一段时间没有使用 maven,所以我不确定文件开关的用途是什么?
Thanks for all the insight!
感谢所有的洞察力!
回答by lotz
The "install-file" or "deploy-file" goals are used for installing or deploying artifacts to your local or internal repository that are not available from Maven Central or other external repositories that you may have configured.
“安装文件”或“部署文件”目标用于将工件安装或部署到本地或内部存储库中,这些工件在 Maven Central 或您可能已配置的其他外部存储库中不可用。
If you've got access to Maven Central, simply adding the following to your project's pom.xml:
如果您可以访问 Maven Central,只需将以下内容添加到您的项目的 pom.xml 中:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
...should do the trick.
...应该可以解决问题。
To answer your question though, the -Dfile= argument is for specifying the artifact that would actually be installed in the local repository.
不过,要回答您的问题, -Dfile= 参数用于指定实际安装在本地存储库中的工件。
回答by Utkarsh Gupta
lotz answer is right and that should be sufficient
lotz的答案是正确的,应该足够了
But, If you want to use the latest version of the connector, you can check https://mvnrepository.com/artifact/mysql/mysql-connector-java
但是,如果您想使用最新版本的连接器,您可以查看https://mvnrepository.com/artifact/mysql/mysql-connector-java
Add the following to your project's pom.xml:
将以下内容添加到项目的 pom.xml 中:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>