maven3.3.9的简单示例以及部署
来源:互联网 发布:dota最强被动晕 知乎 编辑:程序博客网 时间:2024/05/10 05:47
参见:https://maven.apache.org/plugins/maven-deploy-plugin/
1、修改pom.xml 用于deploy
请按照下文 pom.xml 有颜色的内容 修改自己的pom.xml文件:
<?xmlversion="1.0"encoding="UTF-8"?>
<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.chongshi.test</groupId>
<artifactId>hello</artifactId>
<version>1.0</version>
<name>Additional SchemaCrawler Lint</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>us.fatehi</groupId>
<artifactId>schemacrawler-lint</artifactId>
<version>${schemacrawler.version}</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<schemacrawler.version>14.07.03</schemacrawler.version>
</properties>
<distributionManagement>
<repository>
<id>ssh-repo-1</id>
<url>ftp://192.168.83.204/maven-deploy/</url>
</repository>
</distributionManagement>
<build>
<extensions>
<!-- Enabling the use of SSH -->
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>2.10</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
settings.xml文件内容:
<?xmlversion="1.0"encoding="UTF-8"?>
<settings>
<servers>
<server>
<id>ssh-repo-1</id>
<username>root</username>
<password>123456</password>
</server>
</servers>
</settings>
xml:tag:extensions:这部分内容是一个库,
你可以去:
pom.xml 仓库:
http://mvnrepository.com/
按照groupId/artifactId 搜索相关内容。
因为本人使用的ftp,所以artifactId为:wagon-ftp
如果要修改这部分内容,请查阅相关文档! 否则请复制到你pom.xml相应位置即可!
注意:
pom.xml xml:tag:distributionManagement : repository:id 与
settings.xml xml:tag: servers:server:id 保持一致!
在 settings.xml 中,可以很清楚的明白,这个连接配置。
pom.xml xml:tag:distributionManagement: repository:url 表示目标地址
其他请参考:https://maven.apache.org/plugins/maven-deploy-plugin/examples/deploy-ftp.html
2 ftp命令检查,
因为我是从windows上传文件到linux上,一开始我执行命令:mvn deploy 发现:
出现类似如下错误:
registered transporter factories: WagonTransporterFactory: java.util.NoSuchElementException
在window的命令行上:
下面的解决办法参考:http://blog.csdn.net/bamuta/article/details/7448121
执行命令:ftp 192.168.83.204,发现竟然连接拒绝:
ftp: connect: Connection refused
在linux上执行命令: vsftpd /etc/vsftpd/vsftpd.conf &
如果出现:-bash: vsftpd: command not found,说明你的vsftpd没有安装,自己安装一个vsftpd,
可以试试:yum install -y vsftpd
此后再次执行命令:vsftpd /etc/vsftpd/vsftpd.conf &
然后在windows的cmd上执行命令:ftp 192.168.83.204
本人已经可以登录成功,
对于使用root用户登录ftp的:
下面的解决办法参考:http://www.linuxidc.com/Linux/2013-06/85395.htm
我用root登录,出现错误:530 Permission denied解决方法
原来linux的ftp默认不允许使用root登录。
具体解决方法请参考链接 注释掉2个配置文件里的root 即可!
然后使用命令在 windows 的文件夹的url栏输入:ftp://192.168.83.204/
就能访问,在我的文件夹里显示了一个pub文件夹,但是没啥用,主要还是需要你右击文件夹选择登录。
3、开始部署
执行命令:mvn deploy
如果出现问题1:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-cli) on project hello: The packaging for this project did not assign a file to the build artifact -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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 read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
:出现这个问题,可能是因为在执行命令的时候多了一个deploy,或许你的命令是:mvn deploy:deploy,
尝试命令:mvn deploy
如果部署到本地,比如部署到d盘的某个地方,url可以类似如下:
<url>file:///D:\maven_tesyt</url>
如果出现问题3:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project hello: Failed to deploy artifacts: Could not transfer artifact com.chongshi.test:hello:jar:1.0 from/to ssh-repo-1 (ftp://192.168.83.204/maven-deploy/):Password not specified for repository ssh-repo-1 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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 read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
在windows下:
通过命令 mvn deploy -X ,可以发现:
mvn从:[DEBUG] Reading user settings from C:\Users\wangl\.m2\settings.xml
这个位置来读取配置文件:settings.xml
到这个目前去看了下,原来之前的.m2文件夹被我给删掉了,,那么手动创建一个,.m2文件夹。
如果你发现你创建不了这个文件夹,那么请在命令行下创建 mkdir .m2 就可以了,
然后把类似上文中的settings.xml 文件复制到.m2文件夹 这个目录里来!
总之,需要把settings.xml 复制 到.m2文件夹下!
再次执行命令:mvn deploy
出现错误4:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project hello: Failed to deploy artifacts: Could not transfer artifact com.chongshi.test:hello:jar:1.0 from/to ssh-repo-1 (ftp://192.168.83.204/maven-deploy/): Required directory: '/maven-deploy/' is missing -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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 read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
我本人用的url是:ftp://192.168.83.204/maven-deploy/
问题还是出在这个url上。
一般情况下,我们通过ssh进去后,不管是你root还是xxx用户,都会进入到各自的~目录下,所以我在我的~目录 下建立了一个maven-deploy文件夹。
所以在我看来,文件应该传递到ftp://192.168.83.204/maven-deploy/ 这个目录。可是很奇怪,为什么会找不到文件夹/maven-deploy/???
下面的解决方案参考:http://stackoverflow.com/questions/14045094/maven-deploy-file-says-it-succeeded-but-no-files-are-actually-deployed
本人在这个问题上也是耗时了很久,具体就不说了。
反正是参考上面的连接,灵光一现,把绝对路径加上去,所以我使用了url:ftp://192.168.83.204//root/maven-deploy/
再次执行命令。我靠,有文件夹了,有文件了!!!!
注意: 在ip后有一个/,在linux的绝对路径里,路径从跟位置/开始,所以 有2个//在ip+绝对路径的连接处。
我还尝试了url:ftp://192.168.83.204//home/wl/project/maven-deploy/
也成功了。
原来ftp上传,这个url必须使用ip+绝对路径,域名+路径的我没有测试过。
如果出现问题5:
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ hello ---
[INFO] Building jar: C:\Users\wangl\hello\target\hello-1.0.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ hello ---
[INFO] Installing C:\Users\wangl\hello\target\hello-1.0.jar to E:\maven\repo\com\chongshi\test\hello\1.0\hello-1.0.jar
[INFO] Installing C:\Users\wangl\hello\pom.xml to E:\maven\repo\com\chongshi\test\hello\1.0\hello-1.0.pom
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ hello ---
Uploading: ftp://192.168.83.204//home/wl/project/maven-deploy/com/chongshi/test/hello/1.0/hello-1.0.jar
Uploaded: ftp://192.168.83.204//home/wl/project/maven-deploy/com/chongshi/test/hello/1.0/hello-1.0.jar (5 KB at 90.8 KB/sec)
Uploading: ftp://192.168.83.204//home/wl/project/maven-deploy/com/chongshi/test/hello/1.0/hello-1.0.pom
Uploaded: ftp://192.168.83.204//home/wl/project/maven-deploy/com/chongshi/test/hello/1.0/hello-1.0.pom (2 KB at 220.3 KB/sec)
Downloading: ftp://192.168.83.204//home/wl/project/maven-deploy/com/chongshi/test/hello/maven-metadata.xml
Uploading: ftp://192.168.83.204//home/wl/project/maven-deploy/com/chongshi/test/hello/maven-metadata.xml
Uploaded: ftp://192.168.83.204//home/wl/project/maven-deploy/com/chongshi/test/hello/maven-metadata.xml (298 B at 32.3 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.630 s
[INFO] Finished at: 2016-03-18T09:32:50+08:00
[INFO] Final Memory: 12M/224M
[INFO] ------------------------------------------------------------------------
如果出现,上传成功,but没有找到文件,那么也是url问题!
【key:maven update success, but no files】
问题在你的url可能没有指对!!
或者在你的文件夹系统里好好找找,比如url:ftp://192.168.83.204/
【目标是linux】使用这个url,文件并没有被上传到 ~目录,,而是被上传在了 /根目录!
最后,附上我的测试项目:
http://download.csdn.net/detail/oiooooio/9465260
0 0
- maven3.3.9的简单示例以及部署
- 部署ansible以及简单示例
- Maven3 + Hibernate3.6 + MySQL5简单示例
- ZooKeeper的部署以及简单使用
- ZooKeeper的部署以及简单使用
- ZooKeeper的部署以及简单使用
- SpringBoot的简单应用以及部署
- eclipseMars4.5+maven3+jetty8的简单使用
- 部署最简单的三层结构--三层架构示例
- EJB对象的部署及客户端调用简单示例
- Dubbo项目开发及部署的简单示例
- C# 创建、部署和调用WebService的简单示例
- C# 创建、部署和调用WebService的简单示例
- myeclipse中maven3的使用,部署web项目到tomcat7
- myeclipse中maven3的使用,部署web项目到tomcat7
- myeclipse中maven3的使用,部署web项目到tomcat7
- myeclipse中maven3的使用,部署web项目到tomcat7
- Maven3.3.9创建web项目 部署tomcat 8
- jqGrid的时间格式化问题
- Spring整合jsf的管理bean对象
- 找出占用IP的局域网电脑
- Lock & Condition
- mysql 基础配置
- maven3.3.9的简单示例以及部署
- iOS开发--常用技巧 (MJRefresh详解)
- 关于Threading.Timer不工作
- C# 基于SharpPcap的局域网数据包捕获 之一 说在前面
- mysql 优化配置
- gradle修改AndroidManifest.xml中的meta-data元素值
- InnoDB相关参数
- MyISAM相关参数
- MFC(Microsoft Foundation Classes)