zoukankan      html  css  js  c++  java
  • Maven 打包项目 部署到服务器 重启服务 插件

    1、maven插件wagon-maven-plugin自动部署远程Linux服务器  (http://xxgblog.com/2015/10/23/wagon-maven-plugin/)

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>wagon-maven-plugin</artifactId>
                    <version>1.0</version>
                    <configuration>
                        <fromFile>executableJar/${final.name}.jar</fromFile>
                        <url>scp://${user}:${password}@${ip}/data/app/uploadDir</url>
                        <commands>
                            <!--<command>/etc/init.d/nginx stop</command>-->
                            <command>cp /data/app/${final.name}.jar /data/app/uploadDir/${final.name}.jar_`date "+%Y-%m-%d_%H-%M-%S"`</command>
                            <command>sh /data/app/diary-starter.sh stop</command>
                            <command>mv -f /data/app/uploadDir/${final.name}.jar /data/app/${final.name}.jar</command>
                            <command>sh /data/app/diary-starter.sh restart</command>
                            <!--<command>/etc/init.d/nginx start</command>-->
                        </commands>
                        <displayCommandOutputs>true</displayCommandOutputs>
                    </configuration>
                </plugin>

    2、maven插件maven-resources-plugin 设置加载资源文件的时候占位符是否需要被替换

     

      要用到<resource/>标签和maven-resources-plugin插件了,用法如下:

        <build>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering>
                    <excludes>
                        <exclude>application.properties</exclude>
                        <exclude>application-prod.properties</exclude>
                        <exclude>application-test.properties</exclude>
                        <!--<exclude>application-remoteTest.properties</exclude>-->
                        <!--<exclude>application-remoteProd.properties</exclude>-->
                    </excludes>
                </resource>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering>
                    <includes>
                        <include>application.properties</include>
                        <include>application-${profileActive}.properties</include>
                    </includes>
                </resource>
            </resources>
            <finalName>../executableJar/${final.name}</finalName>

      resource的filtering属性用来表示资源文件中的占位符是否需要被替换,true为需要替换

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <configuration>
                        <nonFilteredFileExtensions>
                            <nonFilteredFileExtension>ttf</nonFilteredFileExtension>
                        </nonFilteredFileExtensions>
                    </configuration>
                </plugin>

     以上<nonfilteredFileExtension>作用:maven打包时,会编译特定文件使得文件不可用。用上面的方法可以排除某些文件不编译

  • 相关阅读:
    023-Spring Boot 服务的注册和发现
    022-Spring Boot 构建微服务实战
    021-Spring Boot 测试,Junit方式使用,mock方式,Controller测试
    020-Spring Boot 监控和度量
    003-Spring 中的StreamUtils
    004-微信证书问题
    019-Spring Boot 日志
    018-Spring Boot Starter开发
    017-Spring Boot AOP
    016-Spring Boot JDBC
  • 原文地址:https://www.cnblogs.com/Eeexiang/p/10256752.html
Copyright © 2011-2022 走看看