- 浏览: 2564698 次
- 性别:
- 来自: 成都
-
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
SpringBoot and Maven Release Package
Here is how the project release a tar.gz file for me including the scripts
Here is the important pom.xml parts
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>deployment/release/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>install-external</id>
<phase>clean</phase>
<configuration>
<file>${basedir}/lib/suitetalk-axis-proxy-v2017_2-1.0.0.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>com.netsuitetalk</groupId>
<artifactId>suitetalk-axis-proxy</artifactId>
<version>v2017_2-1.0.0</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
It uses this assembly.xml configuration file to control the output of the tar.gz file
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>bundle</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<!-- script -->
<fileSet>
<directory>bin</directory>
<includes>
<include>*.sh</include>
</includes>
<fileMode>0755</fileMode>
<outputDirectory>bin/</outputDirectory>
</fileSet>
<!-- config files -->
<fileSet>
<directory>src/main/resources</directory>
<includes>
<include>application*.yaml</include>
<include>log4j2.xml</include>
</includes>
<fileMode>0644</fileMode>
<outputDirectory>conf/</outputDirectory>
</fileSet>
<!-- executable jar -->
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>lib/</outputDirectory>
<includes>
<include>${project.artifactId}-${project.version}.jar</include>
</includes>
<fileMode>0755</fileMode>
</fileSet>
<!-- logging -->
<fileSet>
<outputDirectory>logs/</outputDirectory>
<excludes><exclude>**/*</exclude></excludes>
</fileSet>
</fileSets>
</assembly>
Here are some simple examples for shell script
start.sh
#!/bin/sh -ex
nohup java -Djava.net.preferIPv4Stack=true \
-XX:MaxMetaspaceSize=256M -XX:+HeapDumpOnOutOfMemoryError \
-XX:HeapDumpPath="/tmp/dump_oom.hprof" \
-Dspring.config.location=file:./conf/application.yaml \
-Dlogging.config=file:./conf/log4j2.xml \
-jar ./lib/sillycatsuperball-1.0.0.jar > logs/sillycatsuperball.log 2>&1 &
stop.sh
#!/bin/sh -ex
PID=$(ps -ef | grep "sillycatsuperball" | grep -v grep | awk '{ print $2 }')
kill -9 ${PID}
References:
https://www.jianshu.com/p/3bd850fcb488
https://segmentfault.com/a/1190000017386408
https://www.cnblogs.com/littleatp/p/9278517.html
Here is how the project release a tar.gz file for me including the scripts
Here is the important pom.xml parts
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>deployment/release/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>install-external</id>
<phase>clean</phase>
<configuration>
<file>${basedir}/lib/suitetalk-axis-proxy-v2017_2-1.0.0.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>com.netsuitetalk</groupId>
<artifactId>suitetalk-axis-proxy</artifactId>
<version>v2017_2-1.0.0</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
It uses this assembly.xml configuration file to control the output of the tar.gz file
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>bundle</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<!-- script -->
<fileSet>
<directory>bin</directory>
<includes>
<include>*.sh</include>
</includes>
<fileMode>0755</fileMode>
<outputDirectory>bin/</outputDirectory>
</fileSet>
<!-- config files -->
<fileSet>
<directory>src/main/resources</directory>
<includes>
<include>application*.yaml</include>
<include>log4j2.xml</include>
</includes>
<fileMode>0644</fileMode>
<outputDirectory>conf/</outputDirectory>
</fileSet>
<!-- executable jar -->
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>lib/</outputDirectory>
<includes>
<include>${project.artifactId}-${project.version}.jar</include>
</includes>
<fileMode>0755</fileMode>
</fileSet>
<!-- logging -->
<fileSet>
<outputDirectory>logs/</outputDirectory>
<excludes><exclude>**/*</exclude></excludes>
</fileSet>
</fileSets>
</assembly>
Here are some simple examples for shell script
start.sh
#!/bin/sh -ex
nohup java -Djava.net.preferIPv4Stack=true \
-XX:MaxMetaspaceSize=256M -XX:+HeapDumpOnOutOfMemoryError \
-XX:HeapDumpPath="/tmp/dump_oom.hprof" \
-Dspring.config.location=file:./conf/application.yaml \
-Dlogging.config=file:./conf/log4j2.xml \
-jar ./lib/sillycatsuperball-1.0.0.jar > logs/sillycatsuperball.log 2>&1 &
stop.sh
#!/bin/sh -ex
PID=$(ps -ef | grep "sillycatsuperball" | grep -v grep | awk '{ print $2 }')
kill -9 ${PID}
References:
https://www.jianshu.com/p/3bd850fcb488
https://segmentfault.com/a/1190000017386408
https://www.cnblogs.com/littleatp/p/9278517.html
发表评论
-
Update Site will come soon
2021-06-02 04:10 1688I am still keep notes my tech n ... -
Stop Update Here
2020-04-28 09:00 325I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 486NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 375Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 376Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 345Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 437Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 447Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 383Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 469VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 396Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 491NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 433Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 343Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 257GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 458GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 334GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 319Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 327Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 304Serverless with NodeJS and Tenc ...
相关推荐
<version>2.1.4.RELEASE <relativePath/> <!-- lookup parent from repository --> <groupId>com.example</groupId> <artifactId>demo <version>0.0.1-SNAPSHOT <name>demo <description>Demo project for ...
<version>1.3.5.RELEASE ``` - **引入Starter**:通过引入特定的starter,例如`spring-boot-starter-web`,可以快速搭建Web应用的基础环境。 ```xml <groupId>org.springframework.boot <artifactId>...
- 使用默认包(Using the “default” package):建议如何组织项目的包结构。 - 主应用类的位置(Locating the main application class):解释主类的放置位置。 - **配置类**(Configuration classes): - ...
总结来说,通过“springboot环境搭建软件包.rar”,我们可以快速搭建一套完整的SpringBoot开发环境,包括安装JDK、Maven、Eclipse和Spring Boot CLI,然后创建并运行一个简单的SpringBoot项目,展示“Hello World”...
<version>2.0.2.RELEASE ``` Step 6: 添加依赖 在 pom.xml 文件中添加 web 应用基本环境配置的依赖: ```xml <!-- web 应用基本环境配置 --> <groupId>org.springframework.boot <artifactId>spring-boot-...
1. **依赖管理**:SpringBoot通过Maven或Gradle提供了一套标准的依赖管理方案,使得开发者可以方便地引入第三方库,并且这些库已经经过了版本兼容性的验证。 2. **自动配置**:SpringBoot会根据已有的依赖关系自动...
详解用Maven搭建SpringBoot环境的方法 Maven是Java世界中最流行的项目管理工具之一,它可以帮助开发者快速构建和管理项目。SpringBoot是当前最流行的Java框架之一,它可以帮助开发者快速构建基于Spring的应用程序。...
我们可以使用JUnit和Mockito进行单元测试,同时Spring还提供了`@RunWith(SpringRunner.class)`和`@SpringBootTest`注解来进行集成测试。 至于文件`monitor`,这可能是监控或者日志相关的配置或代码,它可能涉及...
配置完成后,运行`mvn package`命令,Maven会生成一个可执行的JAR文件。然后,我们可以用`exec-maven-plugin`将JAR包装成exe。但这个过程通常需要额外的工具,如`launch4j`,它允许我们将Java应用封装为Windows可...
<version>2.5.x.RELEASE</version> <!-- 查看最新Spring Boot版本 --> <type>pom <scope>import <groupId>org.springframework.boot <artifactId>spring-boot-starter-web <groupId>org.spring...
搭建SpringBoot工程是每个开发者在接触...通过这个过程,你不仅了解了如何使用Maven搭建SpringBoot工程,还掌握了配置文件的编写、API接口的创建以及多实例的配置。这些基础知识对于后续的SpringBoot开发至关重要。
然后,配置构建文件`build.gradle`,更新Spring Boot版本至2.1.11.RELEASE,并将Maven仓库地址更改为阿里云的仓库。此外,我们还需要添加MyBatis和Druid的依赖。特别注意,Gbase8s的JDBC驱动需要手动下载并放在项目...
6. **简化部署**:通过 `mvn clean package` 命令将应用打包成可执行的 jar 包,然后使用 `java -jar target/*.jar` 命令运行应用。 #### Spring Boot 的自动配置原理 Spring Boot 自动配置的核心在于 `@SpringBoot...
1. **Maven 清理与打包命令**:`mvn clean package` - `clean`:清理项目构建时产生的临时文件。 - `package`:构建项目并创建可执行的 JAR 或 WAR 文件。 2. **Spring Boot Maven 插件配置**: ```xml ...
package com.chhliu.springboot.starter.helloworld; import org.springframework.boot.context.properties.ConfigurationProperties; / * 描述:人员信息自动配置属性类 * * @author chhliu * 创建时间:2017...
1. **打包项目**:使用Maven命令`mvn clean package`进行打包。 2. **启动应用**:运行`src/main/resources/application.properties`中的主类(通常包含`@SpringBootApplication`注解)。 至此,我们已经成功地使用...
// Getter and Setter 方法 } ``` - **`@ConfigurationProperties`**: 用于绑定配置文件中的属性值到特定的 Java 对象上。 - **`prefix` 属性**: 指定配置属性的前缀,便于在配置文件中引用。 #### 结合使用自动...