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

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

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

項目目錄

問題痛點:

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

解決方案

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

這兩種方案其實都涉及到一個maven打包配置問題

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

1在項目src同級別目錄建

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>
            <!--是否把本項目添加到依賴文件夾下-->
            <useProjectArtifact>true</useProjectArtifact>
            <outputDirectory>lib</outputDirectory>
            <!--將scope為runtime的依賴包打包-->
            <!--<scope>runtime</scope>-->
        </dependencySet>
    </dependencySets>
</assembly>

sh啟動類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/*
#    啟動類路徑
    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)各種問題后,及時的去查找問題,一般注意pom中的配置打包是否沒有把某些包打進(jìn)去還有就是啟動sell腳本通過 ./Aplication.sh start -d 顯示啟動日志

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

相關(guān)文章

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

    SpringBoot中集成日志的四種方式

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

    Mybatis結(jié)果集自動映射的實例代碼

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

    2020最新版SSM框架整合教程

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

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

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

    Java 如何遍歷JsonObject對象

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

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

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

    Eclipse不自動編譯java文件的終極解決方法

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

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

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

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

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

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

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

最新評論

定西市| 香格里拉县| 靖边县| 凉山| 长沙县| 综艺| 辛集市| 西昌市| 汝州市| 疏勒县| 慈利县| 兴国县| 鄂尔多斯市| 崇仁县| 新泰市| 克山县| 新平| 那曲县| 崇仁县| 宝山区| 台中市| 墨江| 井冈山市| 焉耆| 龙州县| 荔波县| 广汉市| 浦江县| 酒泉市| 新巴尔虎左旗| 咸宁市| 左贡县| 正定县| 黎川县| 西峡县| 县级市| 廊坊市| 平利县| 平山县| 长治市| 高唐县|