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

Nacos-SpringBoot框架啟動(dòng)不加載bootstrap.yml的解決

 更新時(shí)間:2022年11月22日 11:26:20   作者:Eistert  
這篇文章主要介紹了Nacos-SpringBoot框架啟動(dòng)不加載bootstrap.yml的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

背景

nacos server 源碼運(yùn)行在本地自己創(chuàng)建的項(xiàng)目中。

正常啟動(dòng)的話,SpringBoot框架會(huì)自動(dòng)加載resource目錄下的bootstrap.yml文件中的配置,日志記錄會(huì)打印相關(guān)日志:

在這里插入圖片描述

Connected to the target VM, address: '127.0.0.1:54696', transport: 'socket'
2021-12-21 16:18:44.639  INFO 8342 --- [           main] c.a.n.c.l.StartingApplicationListener    : Nacos started successfully in stand alone mode. use external storage

         ,--.
       ,--.'|
   ,--,:  : |                                           Nacos 
,`--.'`|  ' :                       ,---.               Running in stand alone mode, All function modules
|   :  :  | |                      '   ,'\   .--.--.    Port: 8848
:   |   \ | :  ,--.--.     ,---.  /   /   | /  /    '   Pid: 8342
|   : '  '; | /       \   /     \.   ; ,. :|  :  /`./   Console: http://192.168.100.43:8848/nacos/index.html
'   ' ;.    ;.--.  .-. | /    / ''   | |: :|  :  ;_
|   | | \   | \__\/: . ..    ' / '   | .; : \  \    `.      https://nacos.io
'   : |  ; .' ," .--.; |'   ; :__|   :    |  `----.   \
|   | '`--'  /  /  ,.  |'   | '.'|\   \  /  /  /`--'  /
'   : |     ;  :   .'   \   :    : `----'  '--'.     /
;   |.'     |  ,     .-./\   \  /            `--'---'
'---'        `--`---'     `----'

2021-12-21 16:18:46.141  INFO 8342 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=71ca1145-0798-3a30-a497-d6b8d15b4f05
2021-12-21 16:18:46.504  INFO 8342 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8848 (http)
2021-12-21 16:18:46.704  INFO 8342 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1780 ms
2021-12-21 16:18:48.714  INFO 8342 --- [           main] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [static/index.html]
2021-12-21 16:18:49.190  INFO 8342 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Will secure Ant [pattern='/**'] with []
2021-12-21 16:18:49.222  INFO 8342 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Will secure any request with [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@20616795, org.springframework.security.web.context.SecurityContextPersistenceFilter@74de1e9d, org.springframework.security.web.header.HeaderWriterFilter@1a927db2, org.springframework.security.web.csrf.CsrfFilter@14abde3e, org.springframework.security.web.authentication.logout.LogoutFilter@7170da18, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@43b9ef41, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@191d69a, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@1b61c1, org.springframework.security.web.session.SessionManagementFilter@4e22fdc0, org.springframework.security.web.access.ExceptionTranslationFilter@281f2d6c]
2021-12-21 16:18:49.270  INFO 8342 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 16 endpoint(s) beneath base path '/actuator'
2021-12-21 16:18:49.374  INFO 8342 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8848 (http) with context path '/nacos'
2021-12-21 16:18:49.396  INFO 8342 --- [           main] c.a.n.c.l.StartingApplicationListener    : Nacos started successfully in stand alone mode. use external storage
2021-12-21 16:18:49.689  INFO 8342 --- [-192.168.100.43] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2021-12-21 16:18:49.691  INFO 8342 --- [-192.168.100.43] o.s.web.servlet.DispatcherServlet        : Completed initialization in 2 ms

但是我把這塊的nocos代碼原封不動(dòng)的copy到的自己的一個(gè)項(xiàng)目中,修改了bootstrap.yml文件中的數(shù)據(jù)庫(kù)連接。

然后啟動(dòng)日志打印卻顯示使用的是embedded storage。

日志如下:

Connected to the target VM, address: '127.0.0.1:54270', transport: 'socket'

         ,--.
       ,--.'|
   ,--,:  : |                                           Nacos 
,`--.'`|  ' :                       ,---.               Running in stand alone mode, All function modules
|   :  :  | |                      '   ,'\   .--.--.    Port: 8848
:   |   \ | :  ,--.--.     ,---.  /   /   | /  /    '   Pid: 8132
|   : '  '; | /       \   /     \.   ; ,. :|  :  /`./   Console: http://192.168.100.43:8848/nacos/index.html
'   ' ;.    ;.--.  .-. | /    / ''   | |: :|  :  ;_
|   | | \   | \__\/: . ..    ' / '   | .; : \  \    `.      https://nacos.io
'   : |  ; .' ," .--.; |'   ; :__|   :    |  `----.   \
|   | '`--'  /  /  ,.  |'   | '.'|\   \  /  /  /`--'  /
'   : |     ;  :   .'   \   :    : `----'  '--'.     /
;   |.'     |  ,     .-./\   \  /            `--'---'
'---'        `--`---'     `----'

2021-12-21 16:17:11.755  WARN 8132 --- [           main] o.s.boot.StartupInfoLogger               : InetAddress.getLocalHost().getHostName() took 5002 milliseconds to respond. Please verify your network configuration (macOS machines may need to add entries to /etc/hosts).
2021-12-21 16:17:20.760  INFO 8132 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8848 (http)
2021-12-21 16:17:21.339  INFO 8132 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4410 ms
2021-12-21 16:17:31.806  INFO 8132 --- [           main] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [static/index.html]
2021-12-21 16:17:32.562  INFO 8132 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Will secure Ant [pattern='/**'] with []
2021-12-21 16:17:32.627  INFO 8132 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Will secure any request with [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@51a06fd5, org.springframework.security.web.context.SecurityContextPersistenceFilter@53c0424a, org.springframework.security.web.header.HeaderWriterFilter@360432d3, org.springframework.web.filter.CorsFilter@71458178, org.springframework.security.web.authentication.logout.LogoutFilter@18487f92, com.alibaba.nacos.filter.JwtAuthenticationTokenFilter@26edfa34, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@408a0e92, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@51a65f56, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@776b7fa2, org.springframework.security.web.session.SessionManagementFilter@6391d34f, org.springframework.security.web.access.ExceptionTranslationFilter@66978c15, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@2e7cd4bb]
2021-12-21 16:17:32.664  INFO 8132 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 1 endpoint(s) beneath base path '/actuator'
2021-12-21 16:17:32.783  INFO 8132 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8848 (http) with context path '/nacos'
2021-12-21 16:17:32.829  INFO 8132 --- [           main] c.a.n.c.l.StartingApplicationListener    : Nacos started successfully in stand alone mode. use embedded storage
2021-12-21 16:17:33.599  INFO 8132 --- [-192.168.100.43] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2021-12-21 16:17:33.602  INFO 8132 --- [-192.168.100.43] o.s.web.servlet.DispatcherServlet        : Completed initialization in 2 ms

原因

原因一

看日志應(yīng)該發(fā)現(xiàn)是服務(wù)沒(méi)有讀取到bootstrap.yml文件中的配置。應(yīng)該就是定位到是bootstrap.yml沒(méi)有被加載。

只要全局引入bootstrap 啟動(dòng)器和配置文件處理器就可以解決這個(gè)問(wèn)題

        <!--bootstrap 啟動(dòng)器-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-bootstrap</artifactId>
        </dependency>
        <!--配置文件處理器-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <!--配置文件加解密-->
        <dependency>
            <groupId>com.github.ulisesbocchio</groupId>
            <artifactId>jasypt-spring-boot-starter</artifactId>
            <version>${jasypt.version}</version>
        </dependency>

原因二

也有可能是自己pom文件排除掉了相關(guān)結(jié)尾的文件,刪掉過(guò)濾器就行。

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • springboot集成RestTemplate及常見(jiàn)的用法說(shuō)明

    springboot集成RestTemplate及常見(jiàn)的用法說(shuō)明

    這篇文章主要介紹了springboot集成RestTemplate及常見(jiàn)的用法說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-10-10
  • springboot?去掉netflix?禁用Eureka的解決方法

    springboot?去掉netflix?禁用Eureka的解決方法

    這篇文章主要介紹了springboot?去掉netflix?禁用Eureka的解決方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-09-09
  • 淺析12306售票算法(java版)

    淺析12306售票算法(java版)

    這篇文章主要介紹了淺析12306售票算法(java版)的相關(guān)資料,需要的朋友可以參考下
    2016-02-02
  • SpringBoot讀取resource目錄下文件失敗的原因及解決方案

    SpringBoot讀取resource目錄下文件失敗的原因及解決方案

    在idea中運(yùn)行時(shí),有些resource下文件讀取工具類(lèi)能夠正常獲取讀取到文件,但是通過(guò)java–jar的方式去運(yùn)行jar包,此時(shí)resource下文件讀取工具類(lèi)讀取文件就失效了,本文就給大家介紹一下SpringBoot讀取resource目錄下文件失敗解決方案,需要的朋友可以參考下
    2023-08-08
  • Java對(duì)象轉(zhuǎn)換的方案分享

    Java對(duì)象轉(zhuǎn)換的方案分享

    這篇文章主要介紹了Java對(duì)象轉(zhuǎn)換的方案分享,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的朋友可以參考一下
    2022-09-09
  • Spring Boot + Jpa(Hibernate) 架構(gòu)基本配置詳解

    Spring Boot + Jpa(Hibernate) 架構(gòu)基本配置詳解

    本篇文章主要介紹了Spring Boot + Jpa(Hibernate) 架構(gòu)基本配置詳解,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • 詳解spring boot 以jar的方式啟動(dòng)常用shell腳本

    詳解spring boot 以jar的方式啟動(dòng)常用shell腳本

    本篇文章主要介紹了詳解spring boot 以jar的方式啟動(dòng)常用shell腳本,具有一定的參考價(jià)值,有興趣的可以了解一下
    2017-09-09
  • Java判斷對(duì)象是否為空的四種方法小結(jié)

    Java判斷對(duì)象是否為空的四種方法小結(jié)

    這篇文章主要介紹了Java判斷對(duì)象是否為空的四種方法,判斷對(duì)象是否為空有多種方法,包括使用==或!=運(yùn)算符直接比較對(duì)象與null,使用Objects.isNull()方法,以及用instanceof運(yùn)算符或Optional類(lèi)進(jìn)行更安全的空值處理,需要的朋友可以參考下
    2024-10-10
  • myeclipse創(chuàng)建servlet_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理

    myeclipse創(chuàng)建servlet_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理

    這篇文章主要為大家詳細(xì)介紹了myeclipse創(chuàng)建servlet的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-07-07
  • 如何用Java的swing編寫(xiě)簡(jiǎn)單計(jì)算器

    如何用Java的swing編寫(xiě)簡(jiǎn)單計(jì)算器

    這篇文章主要給大家介紹了關(guān)于如何用Java的swing編寫(xiě)簡(jiǎn)單計(jì)算器的相關(guān)資料,通過(guò)本文可以設(shè)計(jì)一個(gè)圖形界面的簡(jiǎn)易計(jì)算器,完成簡(jiǎn)單的算術(shù)運(yùn)算符,可以完成加法、減法、乘法、除法和取余運(yùn)算,需要的朋友可以參考下
    2023-12-12

最新評(píng)論

宜兴市| 黔东| 焦作市| 剑河县| 盐源县| 韶关市| 威海市| 嘉定区| 阿图什市| 青铜峡市| 平罗县| 蒲江县| 乌拉特前旗| 镇坪县| 尉氏县| 承德市| 石棉县| 瑞安市| 白河县| 天门市| 南皮县| 陕西省| 阳春市| 香河县| 广州市| 武川县| 娄底市| 宜兰市| 孝感市| 湘西| 宜丰县| 墨脱县| 依安县| 岳阳市| 保定市| 常熟市| 陆川县| 岑巩县| 通道| 土默特左旗| 平昌县|