使用appassembler插件生成启动脚本
appassemblermaven插件可以自动生成跨平台的启动脚本,省去了手工写脚本的麻烦,而且还可以生成jsw的后台运行程序。插件官网:http://www.mojohaus.org/appassembler/appassembler-maven-plugin/,官网介绍了该插件的详细用法。
appassembler的使用很简单,直接在pom文件中加入插件配置。
生成启动脚本之前,需要有一个启动的类:
package org.cellphone; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan; @EnableAutoConfiguration
@ComponentScan("org.cellphone")
public class WarehouseWeb { public static void main(String[] args) {
SpringApplication.run(WarehouseWeb.class, args);
}
}
1. 生成可执行的启动脚本
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>2.0.0</version>
<executions>
<execution>
<id>Make Assembly</id>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions> <configuration>
<!-- 打包的jar,以及maven依赖的jar放到这个目录里面 -->
<repositoryName>lib</repositoryName>
<!-- 可执行脚本的目录 -->
<binFolder>bin</binFolder>
<!-- 配置文件的目标目录 -->
<configurationDirectory>conf</configurationDirectory>
<!-- 拷贝配置文件到上面的目录中 -->
<copyConfigurationDirectory>true</copyConfigurationDirectory>
<!-- 从哪里拷贝配置文件 (默认src/main/config) -->
<configurationSourceDirectory>src/main/resources</configurationSourceDirectory>
<!-- lib目录中jar的存放规则,默认是${groupId}/${artifactId}的目录格式,flat表示直接把jar放到lib目录 -->
<repositoryLayout>flat</repositoryLayout>
<encoding>UTF-8</encoding>
<logsDirectory>logs</logsDirectory>
<!-- 生成脚本的后缀 -->
<binFileExtensions>
<unix>.sh</unix>
</binFileExtensions>
<!-- 生成linux, windows两种平台的执行脚本 -->
<platforms>
<platform>windows</platform>
<platform>unix</platform>
</platforms> <programs>
<program>
<!--指定主类,脚本名。会生成shell/bat两种类型,也可用platforms指定运行平台-->
<mainClass>org.cellphone.WarehouseWeb</mainClass>
<!-- 生成的脚本文件的名称,比如start.sh,你也可以根据你的需要命名成其他名字 -->
<name>WAREHOUSE-WEB</name>
</program>
</programs>
</configuration>
</plugin>
执行 mvn package appassembler:assemble,执行完成之后,在target/appassembler目录就有可执行脚本。
2. 生成后台服务程序
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>2.0.0</version>
<executions>
<execution>
<id>generate-jsw-scripts</id>
<phase>package</phase>
<goals>
<goal>generate-daemons</goal>
</goals>
</execution>
</executions> <configuration>
<!-- 打包的jar,以及maven依赖的jar放到这个目录里面 -->
<repositoryName>lib</repositoryName>
<!-- 可执行脚本的目录 -->
<binFolder>bin</binFolder>
<!-- 配置文件的目标目录 -->
<configurationDirectory>conf</configurationDirectory>
<!-- 拷贝配置文件到上面的目录中 -->
<copyConfigurationDirectory>true</copyConfigurationDirectory>
<!-- 从哪里拷贝配置文件 (默认src/main/config) -->
<configurationSourceDirectory>src/main/resources</configurationSourceDirectory>
<!-- lib目录中jar的存放规则,默认是${groupId}/${artifactId}的目录格式,flat表示直接把jar放到lib目录 -->
<repositoryLayout>flat</repositoryLayout>
<encoding>UTF-8</encoding>
<logsDirectory>logs</logsDirectory>
<daemons>
<daemon>
<id>WAREHOUSE-WEB</id>
<mainClass>org.cellphone.WarehouseWeb</mainClass>
<platforms>
<platform>jsw</platform>
</platforms>
<generatorConfigurations>
<generatorConfiguration>
<generator>jsw</generator>
<includes>
<include>linux-x86-32</include>
<include>linux-x86-64</include>
<include>windows-x86-32</include>
<include>windows-x86-64</include>
</includes>
<configuration>
<property>
<name>configuration.directory.in.classpath.first</name>
<value>conf</value>
</property>
<property>
<name>wrapper.ping.timeout</name>
<value>120</value>
</property>
<property>
<name>set.default.REPO_DIR</name>
<value>lib</value>
</property>
<property>
<name>wrapper.logfile</name>
<value>logs/wrapper.log</value>
</property>
</configuration>
</generatorConfiguration>
</generatorConfigurations>
<jvmSettings>
<!-- jvm参数 -->
<systemProperties>
<systemProperty>com.sun.management.jmxremote</systemProperty>
<systemProperty>com.sun.management.jmxremote.port=1984</systemProperty>
<systemProperty>com.sun.management.jmxremote.authenticate=false</systemProperty>
<systemProperty>com.sun.management.jmxremote.ssl=false</systemProperty>
</systemProperties>
<extraArguments>
<extraArgument>-server</extraArgument>
</extraArguments>
</jvmSettings>
</daemon>
</daemons>
</configuration>
</plugin>
执行mvn clean package appassembler:generate-daemons,执行完成之后,在target\generated-resources\appassembler\jsw\目录里面就有后台运行的程序。
使用appassembler插件生成启动脚本的更多相关文章
- Jboot使用appassembler-maven-plugin插件生成启动脚本
appassembler-maven-plugin介绍: 使用appassembler-maven-plugin插件可自动生成跨平台的启动脚本,可省去手工写脚本的麻烦,而且还可以生成jsw的后台运行程 ...
- 使用appassembler-maven-plugin插件生成启动脚本
appassembler-maven-plugin可以自动生成跨平台的启动脚本,省去了手工写脚本的麻烦,而且还可以生成jsw的后台运行程序. 首先pom引入相关依赖 <build> < ...
- logstash5生成init脚本后台启动
默认情况使用rpm包安装完logstash之后没有启动脚本,这一点我觉得算是开发不够彻底.官网给了一个脚本,需要根据不同的系统版本生成对应的启动脚本,而且官网没有给明使用方法,对于新用户来说算是个坑, ...
- spring boot打包,依赖、配置文件分离,拷贝启动脚本
一.最终打包的目录结构 二.项目结构 三.开始 1.最终打包的目录,可根据自己需要修改. <properties> <mzservice.path>${project.buil ...
- (转)springboot应用启动原理(一) 将启动脚本嵌入jar
转:https://segmentfault.com/a/1190000013489340 Spring Boot Takes an opinionated view of building prod ...
- 《吐血整理》高级系列教程-吃透Fiddler抓包教程(21)-如何使用Fiddler生成Jmeter脚本-上篇
1.简介 通过跟随宏哥的脚步学习宏哥的Jmeter系列文章,.我们知道Jmeter本身可以录制脚本,也可以通过BadBoy,BlazeMeter等工具进行录制,其实Fiddler也可以录制Jmter脚 ...
- 《吐血整理》高级系列教程-吃透Fiddler抓包教程(22)-如何使用Fiddler生成Jmeter脚本-下篇
1.简介 今天这篇文章其实和上一篇差不多也是利用一个fiddler的插件进行Jmeter脚本的导出,开始宏哥想要合在一起写一篇文章,可是结果实践的时候,两个插件还是有区别的,因此为了不绕晕小伙伴或者童 ...
- busybox rootfs 启动脚本分析(二)
上次分析了busybox的启动脚本,这次分析一下init.d中一些脚本的内容. 参考链接 http://www.cnblogs.com/helloworldtoyou/p/6169678.html h ...
- 一篇关于Maven项目的jar包Shell启动脚本
使用Maven作为项目jar包依赖的管理,常常会遇到命令行启动,笔者也是哥菜鸟,在做微服务,以及服务器端开发的过程中,常常会遇到项目的启动需要使用main方法,笔者潜心的研究了很多博客,发现大多写的都 ...
随机推荐
- Mac下使用sublime Text打开隐藏目录
我们用 sublime Text 打开时,默认是看到非隐藏的目录和文件,如下图: 这时候在这个节目,按下 command +shift + 句号 快捷键,会自动切换 隐藏状态的, 这时候就可以切换成下 ...
- 131.006 Unsupervised Learning - Feature Scaling | 非监督学习 - 特征缩放
@(131 - Machine Learning | 机器学习) 1 Feature Scaling transforms features to have range [0,1] according ...
- Redis的基本操作语句
注:以下出现的key.value都需要具体 1.String类型的数据存储获取 set key value:设置key的值为value,若存在则覆盖,不存在则自动创建decrby get key:获取 ...
- order by 多条件查询 case when
场景:在按照条件查询后,排序按照不同的条件排序,以及同一个条件 正序和倒序排序.可以考虑使用. 遇到的排序条件:按照直播的状态,根据条件排序.直播的状态包括:直播.置顶.预告.回放.过期预告.排序条件 ...
- SVG坐标系统和transformation彻底理解
翻译自https://sarasoueidan.com/blog/svg-coordinate-systems/ SVG元素不像传统的HTML elements一样受制于css box model.这 ...
- --Too small initial heap for new size specified
虽然Java屏蔽了一下内存细节,但是有时候,了解一下这些常识还是有好处的,特别是一些面试,总是盯着这些玩意不放手. JVM启动以后,会分配两类内存区域,一类用于开发人员使用,比如保存一些变量,对象等, ...
- 书籍管理系统 -----没有form组件
urls: from django.contrib import admin from django.urls import path,re_path from first import views ...
- [T-ARA][나 어떡해/1977 기억 안나][我怎么办/1977我不记得了]
歌词来源: 我怎么办:https://music.163.com/#/song?id=28111191 1977我不记得了:https://music.163.com/#/song?id=281111 ...
- python30 excel修改模块xlutils
xlrd只读,xlwt只写,xlutils模块则将读写功能结合起来.https://pypi.org/project/xlutils/ 修改excel通过xlutils的copy函数将<clas ...
- python正则二
在python中,我们可以使用re模块来使用正则表达式. 正则表达式使用\对特殊字符进行转义,因为python本身也是用\作为转义,所以在使用正则的时候会出现这样的情况,'python\\.org', ...