最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

使用springBoot項(xiàng)目配置文件位置調(diào)整到打包外

 更新時(shí)間:2021年08月10日 17:27:47   作者:langzilige  
這篇文章主要介紹了使用springBoot項(xiàng)目配置文件位置調(diào)整到打包外,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

項(xiàng)目目錄

問題痛點(diǎn):

當(dāng)我們打包一個(gè)項(xiàng)目的時(shí)候,springboot打包的jar都是把resouce下的配置文件打進(jìn)去了,這樣就沒發(fā)修改配置文件

解決方案

  • 1.打包的時(shí)候指定打包路徑
  • 2.將配置文件從resouce下面移出來

這兩種方案其實(shí)都涉及到一個(gè)maven打包配置問題

首先來談?wù)剬⑴渲梦募膔esouce下面移出來怎么解決

1在項(xiàng)目src同級(jí)別目錄建

config目錄

2.將resouce下的

application.yaml 文件移到config目錄下方便打包后可以配置application文件中相關(guān)配置

pom.xml中的打包配置

 <build>
        <resources>
            <resource>
                <directory>config</directory>
                <includes>
                    <include>*.yaml</include>
                    <include>*.xml</include>
                    <include>*.conf</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
<!--過濾掉的 -->
                <!--                <excludes>-->
                <!--                    <exclude>**/*.properties</exclude>-->
                <!--                    <exclude>**/*.xml</exclude>-->
                <!--                    <exclude>**/*.yml</exclude>-->
                <!--                </excludes>-->
                <filtering>false</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions></executions>
                <configuration>
                    <!-- 生成可執(zhí)行的jar的名字:xxx-exec.jar -->
                    <!-- 不固定,寫成abcd都可以 -->
                    <classifier>exec</classifier>
                    <mainClass>com.cloudwise.douc.zabbix.api.DoucZabbixApplication</mainClass>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptors>
                        <descriptor>src/main/assembly/assembly.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

assembly.xml配置

<assembly
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
        xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
    <id>bin</id>
    <formats>
        <format>tar.gz</format>
    </formats>
    <includeBaseDirectory>true</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>${project.basedir}</directory>
            <outputDirectory>./</outputDirectory>
            <includes>
                <include>README*</include>
                <include>LICENSE*</include>
                <include>NOTICE*</include>
            </includes>
        </fileSet>
        <fileSet>
            <directory>config</directory>
            <outputDirectory>config</outputDirectory>
        </fileSet>
        <fileSet>
            <directory>bin</directory>
            <outputDirectory>bin</outputDirectory>
            <fileMode>777</fileMode>
        </fileSet>
        <fileSet>
            <directory>target</directory>
            <outputDirectory>lib</outputDirectory>
            <includes>
                <include>*.jar</include>
            </includes>
        </fileSet>
    </fileSets>
    <dependencySets>
        <dependencySet>
            <!--是否把本項(xiàng)目添加到依賴文件夾下-->
            <useProjectArtifact>true</useProjectArtifact>
            <outputDirectory>lib</outputDirectory>
            <!--將scope為runtime的依賴包打包-->
            <!--<scope>runtime</scope>-->
        </dependencySet>
    </dependencySets>
</assembly>

sh啟動(dòng)類shell腳本

#!/bin/bash
PWDPATH=`dirname $0`
COMM_HOME=`cd $PWDPATH && cd .. && pwd`
cd $COMM_HOME
start () {
    JVM_OPTS="
     -server
     -Xms1g
     -Xmx1g
     -XX:+AlwaysPreTouch
     -XX:+UseG1GC
     -XX:MaxGCPauseMillis=2000
     -XX:GCTimeRatio=4
     -XX:InitiatingHeapOccupancyPercent=30
     -XX:G1HeapRegionSize=8M
     -XX:ConcGCThreads=2
     -XX:G1HeapWastePercent=10
     -XX:+UseTLAB
     -XX:+ScavengeBeforeFullGC
     -XX:+DisableExplicitGC
     -XX:+PrintGCDetails
     -XX:-UseGCOverheadLimit
     -XX:+PrintGCDateStamps
     -Xloggc:logs/gc.log
     -Dlog4j2.configurationFile=config/log4j2.xml
    "
    export CLASSPATH=$JAVA_HOME/jre/lib/*:$JAVA_HOME/lib/*:$COMM_HOME/lib/*
#    啟動(dòng)類路徑
    export MAINCLASS="com.gug.api.AdimApplication"
    case $1 in
    -b )
        nohup java $JVM_OPTS -cp $CLASSPATH $MAINCLASS 1>/dev/null 2>&1 &
    ;;
    -d )
        java $JVM_OPTS -classpath $CLASSPATH $MAINCLASS
    ;;
    esac
    echo -e '\r'
}
case $1 in
restart )
    echo stop
    PID=`ps avx|grep $COMM_HOME|grep -v 'grep'|awk '{print $1}'`
    if  [ ! -n "$PID" ] ;then
       echo "The current process does not exist."
    else
       kill $PID
       echo "The process has been successfully stopped."
    fi
    echo start
    if [ ! -n "$2" ] ;then
	echo "After start, you must add parameters -d or -b. See help for details."
    else
        start $2 -b
    fi
;;
start )
    echo start
    if [ ! -n "$2" ] ;then
	echo "After start, you must add parameters -d or -b. See help for details."
    else
        start $2
    fi
;;
stop )
    echo stop
    PID=`ps avx|grep $COMM_HOME|grep -v 'grep'|awk '{print $1}'`
    if  [ ! -n "$PID" ] ;then
       echo "The current process does not exist."
    else
       kill $PID
       echo "The process has been successfully stopped."
    fi
;;
pid )
    PID=`ps avx|grep $COMM_HOME|grep -v 'grep'|awk '{print $1}'`
    if  [ ! -n "$PID" ] ;then
       echo "The current process does not exist."
    else
       echo "pid : "${PID}
    fi
;;
status )
    PID=`ps avx|grep $COMM_HOME|grep -v 'grep'|awk '{print $1}'`
    if  [ ! -n "$PID" ] ;then
       echo "dead"
    else
       echo "running"
    fi
;;
help )
    echo 'start    -d or -b     Start the service DEBUG mode or background mode.'
    echo 'stop                  Stop the service running in the background.'
    echo 'pid                   Gets the current process id information.'
    echo 'status                Gets the current service status information.'
;;
* )
    echo Command error, please enter help
;;
esac

總結(jié):

當(dāng)打包過程中出現(xiàn)各種問題后,及時(shí)的去查找問題,一般注意pom中的配置打包是否沒有把某些包打進(jìn)去還有就是啟動(dòng)sell腳本通過 ./Aplication.sh start -d 顯示啟動(dòng)日志

到此這篇使用springBoot項(xiàng)目配置文件位置調(diào)整到打包外文章就介紹到這了,更多相關(guān)springBoot項(xiàng)目配置文件位置調(diào)整到打包外的內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • SpringBoot中集成日志的四種方式

    SpringBoot中集成日志的四種方式

    在開發(fā)中,日志記錄是保障應(yīng)用程序健壯性、可維護(hù)性的重要手段,通過日志,我們可以記錄系統(tǒng)的運(yùn)行狀態(tài)、捕獲異常并進(jìn)行調(diào)試,Spring Boot 默認(rèn)使用的是 Logback,但你也可以根據(jù)需求選擇其他框架,以下是幾種常用的日志集成方法,需要的朋友可以參考下
    2024-10-10
  • Mybatis結(jié)果集自動(dòng)映射的實(shí)例代碼

    Mybatis結(jié)果集自動(dòng)映射的實(shí)例代碼

    在使用Mybatis時(shí),有的時(shí)候我們可以不用定義resultMap,而是直接在<select>語(yǔ)句上指定resultType。這個(gè)時(shí)候其實(shí)就用到了Mybatis的結(jié)果集自動(dòng)映射,下面通過本文給大家分享Mybatis結(jié)果集自動(dòng)映射的實(shí)例代碼,一起看看吧
    2017-02-02
  • 2020最新版SSM框架整合教程

    2020最新版SSM框架整合教程

    這篇文章主要介紹了2020最新版SSM框架整合教程,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • JavaFX如何獲取ListView(列表視圖)的選項(xiàng)

    JavaFX如何獲取ListView(列表視圖)的選項(xiàng)

    這篇文章主要介紹了JavaFX如何獲取ListView(列表視圖)的選項(xiàng),具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-01-01
  • Java 如何遍歷JsonObject對(duì)象

    Java 如何遍歷JsonObject對(duì)象

    這篇文章主要介紹了Java 如何遍歷JsonObject對(duì)象?今天小編就為大家分享一篇Java遍歷JsonObject對(duì)象案例,希望對(duì)大家有所幫助吧
    2021-01-01
  • Java 集合實(shí)現(xiàn)分頁(yè)的方法(業(yè)務(wù)代碼實(shí)現(xiàn)分頁(yè))

    Java 集合實(shí)現(xiàn)分頁(yè)的方法(業(yè)務(wù)代碼實(shí)現(xiàn)分頁(yè))

    在Java開發(fā)中,有些場(chǎng)景比較復(fù)雜,受限制,不好在sql查詢層面實(shí)現(xiàn)分頁(yè),需要在查詢的list結(jié)果后,將list分頁(yè)返回,如何實(shí)現(xiàn)呢,帶著這個(gè)問題一起通過本文學(xué)習(xí)吧
    2025-02-02
  • Eclipse不自動(dòng)編譯java文件的終極解決方法

    Eclipse不自動(dòng)編譯java文件的終極解決方法

    這篇文章主要介紹了Eclipse不自動(dòng)編譯java文件的終極解決方法,需要的朋友可以參考下
    2015-12-12
  • 解析Java并發(fā)Exchanger的使用

    解析Java并發(fā)Exchanger的使用

    Exchanger是java 5引入的并發(fā)類,Exchanger顧名思義就是用來做交換的。這里主要是兩個(gè)線程之間交換持有的對(duì)象。當(dāng)Exchanger在一個(gè)線程中調(diào)用exchange方法之后,會(huì)等待另外的線程調(diào)用同樣的exchange方法。兩個(gè)線程都調(diào)用exchange方法之后,傳入的參數(shù)就會(huì)交換。
    2021-06-06
  • springboot整合quartz實(shí)現(xiàn)定時(shí)任務(wù)示例

    springboot整合quartz實(shí)現(xiàn)定時(shí)任務(wù)示例

    spring支持多種定時(shí)任務(wù)的實(shí)現(xiàn)。我們來介紹下使用spring的定時(shí)器和使用quartz定時(shí)器,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。
    2017-04-04
  • 小議Java的源文件的聲明規(guī)則以及編程風(fēng)格

    小議Java的源文件的聲明規(guī)則以及編程風(fēng)格

    這篇文章主要介紹了小議Java的源文件的聲明規(guī)則以及編程風(fēng)格,僅給Java初學(xué)者作一個(gè)簡(jiǎn)單的示范,需要的朋友可以參考下
    2015-09-09

最新評(píng)論

遵义市| 博白县| 新建县| 沈阳市| 安徽省| 淄博市| 莲花县| 庆阳市| 呼和浩特市| 巴塘县| 盐源县| 东丽区| 六枝特区| 长岛县| 翼城县| 措勤县| 漯河市| 水城县| 兴和县| 天柱县| 连云港市| 安阳市| 拜城县| 新丰县| 内丘县| 镇平县| 渑池县| 信丰县| 革吉县| 金沙县| 德江县| 临武县| 甘孜| 铅山县| 麻栗坡县| 长宁区| 顺昌县| 贵港市| 岑巩县| 张家界市| 荔波县|