欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Nacos-SpringBoot框架啟動不加載bootstrap.yml的解決

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

背景

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

正常啟動的話,SpringBoot框架會自動加載resource目錄下的bootstrap.yml文件中的配置,日志記錄會打印相關日志:

在這里插入圖片描述

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代碼原封不動的copy到的自己的一個項目中,修改了bootstrap.yml文件中的數(shù)據(jù)庫連接。

然后啟動日志打印卻顯示使用的是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

原因

原因一

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

只要全局引入bootstrap 啟動器和配置文件處理器就可以解決這個問題

        <!--bootstrap 啟動器-->
        <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文件排除掉了相關結尾的文件,刪掉過濾器就行。

    <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>

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

相關文章

  • 通過實例了解java checked和unchecked異常

    通過實例了解java checked和unchecked異常

    這篇文章主要介紹了通過實例了解checked和unchecked異常,Java異常分為兩種類型,checked異常和unchecked異常,另一種叫法是異常和錯誤。下面小編就帶大家來一起學習一下吧
    2019-06-06
  • Java圖形界面開發(fā)之簡易記事本

    Java圖形界面開發(fā)之簡易記事本

    這篇文章主要為大家詳細介紹了Java圖形界面開發(fā)之簡易記事本的制作方法,,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-10-10
  • Java生成唯一id的幾種實現(xiàn)方式

    Java生成唯一id的幾種實現(xiàn)方式

    本文主要介紹了Java生成唯一id的幾種實現(xiàn)方式,主要介紹了5種方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2024-01-01
  • jtds1.1連接sqlserver2000測試示例

    jtds1.1連接sqlserver2000測試示例

    這篇文章主要介紹了jtds1.1連接sqlserver2000測試示例,需要的朋友可以參考下
    2014-02-02
  • java八大經(jīng)典書籍 你看過幾本?

    java八大經(jīng)典書籍 你看過幾本?

    java八大經(jīng)典書籍,你看過幾本?本文為大家分享了java學習書單,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-01-01
  • Java實現(xiàn)心跳機制的方法

    Java實現(xiàn)心跳機制的方法

    這篇文章主要介紹了Java實現(xiàn)心跳機制的方法,文中講解非常細致,幫助大家更好的理解和學習,感興趣的朋友可以了解下
    2020-07-07
  • JPA Specification常用查詢+排序實例

    JPA Specification常用查詢+排序實例

    這篇文章主要介紹了JPA Specification常用查詢+排序實例,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-11-11
  • Spring中的@ExceptionHandler注解統(tǒng)一異常處理詳解

    Spring中的@ExceptionHandler注解統(tǒng)一異常處理詳解

    這篇文章主要介紹了Spring中的@ExceptionHandler注解統(tǒng)一異常處理詳解,當我們使用這個@ExceptionHandler注解時,定義一個異常的處理方法,加上@ExceptionHandler注解,這個方法就會處理類中其他方法拋出的異常,需要的朋友可以參考下
    2024-01-01
  • SpringBoot整合SpringTask實現(xiàn)定時任務的流程

    SpringBoot整合SpringTask實現(xiàn)定時任務的流程

    這篇文章主要介紹了SpringBoot整合SpringTask實現(xiàn)定時任務的流程,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-06-06
  • 使用SpringSecurity處理CSRF攻擊的方法步驟

    使用SpringSecurity處理CSRF攻擊的方法步驟

    這篇文章主要介紹了使用SpringSecurity處理CSRF攻擊的方法步驟,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-03-03

最新評論