• 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打包时,会编译特定文件使得文件不可用。用上面的方法可以排除某些文件不编译

  • 相关阅读:
    hdu1049Climbing Worm
    hdu1290献给杭电五十周年校庆的礼物
    hduNumber Sequence
    VS2012创建项目模板创建vsix扩展组件
    那些热血沸腾的电子竞技背景音乐
    学习总结
    学习总结第六周
    第二次课堂测试1
    学习总结第五周
    一个简单的学生成绩管理系统(用JAVA实现)
  • 原文地址:https://www.cnblogs.com/Eeexiang/p/10256752.html
Copyright © 2020-2023  润新知