时间:2020-10-01 15:47:37 | 栏目:JAVA代码 | 点击:次
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] ------------------------------------------------------------------------