当前位置:   article > 正文

spring boot pom打包配置+linux启动脚本 提高打包部署速度_spring boot 如何提高打包速度

spring boot 如何提高打包速度
spring boot在打包时候利用maven打包控件以及启动脚本配置,将配置文件打包到jar包的外面,方便配置部署。
  • 1

1. spring boot maven打包控件

 <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>1.5.7</version>
            </plugin>
        </plugins>
    </build>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

2. maven打包控件
在打包时请在maven中选定no_config profile

 <profiles>
        <profile>
            <id>no_config</id>
            <build>
                <resources>
                    <resource>
                        <directory>src/main/resources</directory>
                        <includes>
                            <include>*/**</include>
                        </includes>
                        <excludes>
                            <exclude>
                                config/*.properties
                            </exclude>
                            <exclude>
                                *.properties
                            </exclude>
                            <exclude>
                                *.xml
                            </exclude>
                        </excludes>
                    </resource>
                </resources>
                <plugins>
                    <plugin> <!--jdk版本设置-->
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <source>${jdk.version}</source>
                            <target>${jdk.version}</target>
                            <compilerArguments>
                                <bootclasspath>C:\Program Files\Java\jdk1.8.0_141\jre\lib\rt.jar</bootclasspath>
                            </compilerArguments>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38

3. 启动jar包与配置文件放置说明

请将打包的spring boot jar包与配置文件放置在同一文件目录,例如文件目录
  • 1

这里写图片描述
4. 配置启动脚本

cd /xxx/spring-boot-demo #项目目录
#export LC_CTYPE=zh_CN.GBK
path='/xxx/spring-boot-demo'#项目目录
year=`date +%Y`
month=`date +%m`
day=`date +%d`
echo Running ...

if [ ! -d $path/log/$year/$month/$day ];then
        mkdir -p $path/log/$year/$month/$day
fi

nohup  /usr/jdk1.8.0_40/bin/java -jar -Xmx2048m  -Xms1024m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=6666  -Dspring.profiles.active=local -Dlogging.config=./logback.xml   spring-boot-demo.jar >> /dev/null  2>&1  &
echo  The end!
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号