温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

javawagon中怎么将文件打包到不同服务器

发布时间:2021-07-20 15:38:51 来源:亿速云 阅读:112 作者:Leah 栏目:编程语言

javawagon中怎么将文件打包到不同服务器,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

java需要编译的,打包后文件要上传到服务器。推荐二个办法,

第一种,用jenkins,可以使用centos7 jenkins 发布vue ssr,编译类的语言都可能过jenkins来发布,.net没试过。

第二种,用wagon包来实现

1,修改pom.xml

<build>  <plugins>   <plugin>    <groupId>org.codehaus.mojo</groupId>    <artifactId>wagon-maven-plugin</artifactId>    <version>1.0</version>    <configuration>     <serverId>${profiles.active}</serverId>     <fromFile>target/test.jar</fromFile>     <url>scp://root@${profiles.url}/var/www/java/target</url>    </configuration>   </plugin>  </plugins>  <extensions>   <extension>    <groupId>org.apache.maven.wagon</groupId>    <artifactId>wagon-ssh</artifactId>    <version>2.8</version>   </extension>  </extensions> </build>  <profiles>  <profile>   <!-- staging -->   <id>nlj-staging</id>   <properties>    <profiles.active>nlj-staging</profiles.active>    <profiles.resource>staging</profiles.resource>    <profiles.url>10.0.0.12</profiles.url>    <profiles.updatePolicy>always</profiles.updatePolicy   </properties>   <activation>    <activeByDefault>true</activeByDefault>   </activation>  </profile>  <profile>   <id>nlj-bms-prod</id>   <properties>    <profiles.active>nlj-bms-prod</profiles.active>    <profiles.resource>production</profiles.resource>    <profiles.url>47.111.11.11</profiles.url>    <profiles.updatePolicy>always</profiles.updatePolicy>  </properties>  </profile> </profiles>

配置完,重新加载maven包。

2,打包,并上传

# mvn clean package -Pnlj-staging -Dmaven.test.skip=true # mvn wagon:upload-single -Pnlj-staging 。。。。。。。。。。。。。。省略。。。。。。。。。。。。。。 [INFO] --- wagon-maven-plugin:1.0:upload-single (default-cli) @ test --- Password for root@10.0.0.12: ******* [INFO] Uploading: /Users/zhangying/Documents/www/target/test.jar scp://10.0.0.12/var/www/java/target/test.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 40.392 s [INFO] Finished at: 2019-03-29T18:48:07+08:00 [INFO] Final Memory: 14M/176M [INFO] ---------------------------------------------------

看完上述内容,你们掌握javawagon中怎么将文件打包到不同服务器的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI