• 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命名的配置文件。

  • 相关阅读:
    vulnhub-xxe靶场通关(xxe漏洞续)
    2023_Spark_实验七:Scala函数式编程部分演示
    【Proteus】:LCD1602仿真实验基于STM32CubeMX
    网络安全--红队资源大合集
    【JavaEE网络】TCP/IP协议:细节与应用
    LIO-SAM框架:点云匹配前戏之初值计算及局部地图构建
    Cyanine5-COOH,Cy5 COOH荧光染料146368-11-8星戈瑞
    一直以来,人们都在试图寻找产业互联网真实的样子
    事业编招聘:雄安新区公开选聘专业骨干人才
    SpringBoot 配置文件
  • 原文地址:https://blog.csdn.net/hchyboy/article/details/106254989