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

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

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>

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>

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

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

这里写图片描述
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!
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值