将jar部署到maven内部仓库

我创build了一个maven内部存储库。 我有没有使用maven创build的jar,即没有pom.xml文件。 我需要将这个jar部署到我创build的内部存储库。 为此,我使用了mvn deploy:deploy-file。 以下是我用过的命令 –

mvn -X deploy:deploy-file -Durl = scp:// localhost / my-repo / -DrepositoryId = localhost -Dfile = temp.jar -DgroupId = com.myorg -DartifactId = temp -Dversion = 1.0 -Dpackaging = jar – Dclassifier = test -DgeneratePom = true -DgeneratePom.description =“temp test”-DrepositoryLayout = default -DuniqueVersion = false

我使用的是Windows XP和Apache-Maven-3.0.3。 我得到以下错误 –

“[错误]无法执行目标org.apache.maven.plugins:maven-deploy-plugin:2.5:部署文件(default-cli)项目standalone-pom:部署工件/元数据失败:没有连接器可用于访问版本库localhost(scp:// localhost / commons-logging /)typesdefault使用可用的工厂WagonRepositoryConnectorFactory“

我从来没有在Windows上使用scp,因为我已经在linux机器上工作,我也不需要安装它来实现这个任务,然后我可以从哪里安装它,以及如何克服我面临的错误。 请指导我关于这个问题。

谢谢!!

你不提这个存储库是什么。 如果问题存储库是您的本地机器存储库,您可以这样做:

mvn install:install-file -DgroupId=javax.transaction -DartifactId=jta -Dpackaging=jar -Dversion=1.0.1B -Dfile=jta-1.0.1B.jar -DgeneratePom=true 

如果存储库是类似Nexus的,那么使用他们的UI来上传这个工件,它会为你创建一个pom。

mvn deploy:deploy-file -Durl=scp://d8u.us/home/hd1/public_html/maven2 -DrepositoryId=localhost -Dfile=yourwar.jar -DgroupId=us.d8u -DartifactId=yourwar -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true -DrepositoryLayout=default -DuniqueVersion=false适用于我。 我只需要在我的主目录下创建maven2目录,并为Web用户设置适当的权限,然后剥夺Sierra先生的博客,在那里他慷慨地为我提供了接近工作的指导 。

我有同样的问题,通过SSH部署一个专有的第三方jar到我们的内部仓库。 我结束了使用一个小的Ant脚本,我觉得它比Maven类路径摆弄更安全。

 <?xml version="1.0"?> <project name="Maven Deploy" xmlns:artifact="antlib:org.apache.maven.artifact.ant"> <property name="repository.id" value="myrepository"/> <property name="repository.url" value="sftp://dev.example.com/var/www/mvn"/> <target name="init"> <mkdir dir="target/lib"/> <get src="http://repo1.maven.org/maven2/org/apache/maven/maven-ant-tasks/2.1.3/maven-ant-tasks-2.1.3.jar" dest="target/lib" skipexisting="true"/> <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpath="target/lib/maven-ant-tasks-2.1.3.jar"/> <artifact:install-provider artifactId="wagon-ssh" version="2.2"/> </target> <target name="deploy" depends="init"> <echo>Deploy a jar to the Maven repository:</echo> <input addproperty="groupId" message="groupId:"/> <input addproperty="artifactId" message="artifactId:"/> <input addproperty="version" message="version:"/> <input addproperty="file" message="file:" defaultvalue="${artifactId}-${version}.jar"/> <artifact:mvn failonerror="true"> <arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file"/> <arg value="-DgroupId=${groupId}"/> <arg value="-DartifactId=${artifactId}"/> <arg value="-Dversion=${version}"/> <arg value="-Durl=${repository.url}"/> <arg value="-DrepositoryId=${repository.id}"/> <arg value="-Dfile=${file}"/> </artifact:mvn> </target> </project> 

只需键入ant deploy并指定您的文件的groupId,artifactId和版本。