• spring boot-Resolved element must not contain multiple elements 警告


    首先强调一下,此问题不影响程序运行。

    报错信息:

    1. package org.springframework.util;
    2. ...
    3. public abstract class Assert
    4. ...
    5. public static void state(boolean expression, String message) {
    6. if (!expression) {
    7. throw new IllegalStateException(message); //此处报错
    8. }
    9. }
    10. add:873, ConfigurationPropertyName$ElementsParser (org.springframework.boot.context.properties.source)
    11. parse:820, ConfigurationPropertyName$ElementsParser (org.springframework.boot.context.properties.source)
    12. adapt:569, ConfigurationPropertyName (org.springframework.boot.context.properties.source)
    13. convertName:61, SystemEnvironmentPropertyMapper (org.springframework.boot.context.properties.source)
    14. map:52, SystemEnvironmentPropertyMapper (org.springframework.boot.context.properties.source)
    15. map:245, SpringConfigurationPropertySource$DelegatingPropertyMapper (org.springframework.boot.context.properties.source)
    16. map:238, SpringConfigurationPropertySource$DelegatingPropertyMapper (org.springframework.boot.context.properties.source)
    17. getPropertyMappings:118, SpringIterableConfigurationPropertySource (org.springframework.boot.context.properties.source)
    18. getConfigurationProperty:72, SpringIterableConfigurationPropertySource (org.springframework.boot.context.properties.source)
    19. findConfigurationProperty:65, ConfigurationPropertySourcesPropertySource (org.springframework.boot.context.properties.source)
    20. findConfigurationProperty:53, ConfigurationPropertySourcesPropertySource (org.springframework.boot.context.properties.source)
    21. getProperty:42, ConfigurationPropertySourcesPropertySource (org.springframework.boot.context.properties.source)
    22. get:206, SpringApplicationJsonEnvironmentPostProcessor$JsonPropertyValue (org.springframework.boot.env)
    23. apply:-1, 1671507048 (org.springframework.boot.env.SpringApplicationJsonEnvironmentPostProcessor$$Lambda$41)
    24. accept:193, ReferencePipeline$3$1 (java.util.stream)
    25. tryAdvance:958, Spliterators$ArraySpliterator (java.util)
    26. forEachWithCancel:126, ReferencePipeline (java.util.stream)
    27. copyIntoWithCancel:498, AbstractPipeline (java.util.stream)
    28. copyInto:485, AbstractPipeline (java.util.stream)
    29. wrapAndCopyInto:471, AbstractPipeline (java.util.stream)
    30. evaluateSequential:152, FindOps$FindOp (java.util.stream)
    31. evaluate:234, AbstractPipeline (java.util.stream)
    32. findFirst:464, ReferencePipeline (java.util.stream)
    33. postProcessEnvironment:95, SpringApplicationJsonEnvironmentPostProcessor (org.springframework.boot.env)
    34. onApplicationEnvironmentPreparedEvent:188, ConfigFileApplicationListener (org.springframework.boot.context.config)
    35. onApplicationEvent:176, ConfigFileApplicationListener (org.springframework.boot.context.config)
    36. doInvokeListener:172, SimpleApplicationEventMulticaster (org.springframework.context.event)
    37. invokeListener:165, SimpleApplicationEventMulticaster (org.springframework.context.event)
    38. multicastEvent:139, SimpleApplicationEventMulticaster (org.springframework.context.event)
    39. multicastEvent:127, SimpleApplicationEventMulticaster (org.springframework.context.event)
    40. environmentPrepared:76, EventPublishingRunListener (org.springframework.boot.context.event)
    41. environmentPrepared:53, SpringApplicationRunListeners (org.springframework.boot)
    42. prepareEnvironment:345, SpringApplication (org.springframework.boot)
    43. run:308, SpringApplication (org.springframework.boot)
    44. run:1226, SpringApplication (org.springframework.boot)
    45. run:1215, SpringApplication (org.springframework.boot)
    46. main:14, MonitorApplication (com.deyou.cabin.monitor)

    解决过程:

    跟踪观察,在上面的对应行数添加断点,发现是files\Java\jdk1.8 配置读取时出现问题。应该是本人使用了JC_Jenv设置出现了错误。查看环境变量:

    红框内位置是不纯在的。

    问题解决方法:

    删除了JAVA_HOME环境变量,JC_jenv不设置java的路径在C盘的路径,使用JC_jenv对java版本进行正确管理,修改完后的截图如下

    注意:修改完后windows需要重启系统才可以。

    思路总结:

    根据上面报错的代码路线,断点跟踪发现,是加载resources的名称是files\Java\jdk1.8 时出现了错误,getConfigurationProperty 解析的就是resources,所以就去环境变量中去寻找对应关系。

    引申知识: 

    spring boot 初始化加载机制:ConfigFileApplicationListener加载file:./config,file:,classpath:/config,classpath:。这4个路径下的application命名的配置文件。

  • 相关阅读:
    20天拿下华为OD笔试之【模拟】2023B-查字典【欧弟算法】全网注释最详细分类最全的华为OD真题题解
    go mod出现zip: not a valid zip file的解决办法
    基于ArcGIS水文分析、HEC-RAS模拟技术在洪水危险性及风险评估
    Hudi(三)集成Flink
    小米OPPO三星一加红魔全机型解锁BL详细教程合集-ROOT刷机必要操作
    前端---ES5知识点小梳理三
    VMware虚拟机中libreoffice无法输入中文,如何解决?(操作系统-linux)
    接着聊聊如何从binlog文件恢复误delete的数据,模拟Oracle的闪回功能
    C# Tryparse的使用说明
    Java全栈解密:从JVM内存管理到Spring框架,揭秘垃圾回收、类加载机制与Web开发精髓的全方位旅程
  • 原文地址:https://blog.csdn.net/hchyboy/article/details/106254989