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

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

报错信息:

package org.springframework.util;
...

public abstract class Assert
...

public static void state(boolean expression, String message) {
    if (!expression) {
        throw new IllegalStateException(message); //此处报错
    }
}
add:873, ConfigurationPropertyName$ElementsParser (org.springframework.boot.context.properties.source)
parse:820, ConfigurationPropertyName$ElementsParser (org.springframework.boot.context.properties.source)
adapt:569, ConfigurationPropertyName (org.springframework.boot.context.properties.source)
convertName:61, SystemEnvironmentPropertyMapper (org.springframework.boot.context.properties.source)
map:52, SystemEnvironmentPropertyMapper (org.springframework.boot.context.properties.source)
map:245, SpringConfigurationPropertySource$DelegatingPropertyMapper (org.springframework.boot.context.properties.source)
map:238, SpringConfigurationPropertySource$DelegatingPropertyMapper (org.springframework.boot.context.properties.source)
getPropertyMappings:118, SpringIterableConfigurationPropertySource (org.springframework.boot.context.properties.source)
getConfigurationProperty:72, SpringIterableConfigurationPropertySource (org.springframework.boot.context.properties.source)
findConfigurationProperty:65, ConfigurationPropertySourcesPropertySource (org.springframework.boot.context.properties.source)
findConfigurationProperty:53, ConfigurationPropertySourcesPropertySource (org.springframework.boot.context.properties.source)
getProperty:42, ConfigurationPropertySourcesPropertySource (org.springframework.boot.context.properties.source)
get:206, SpringApplicationJsonEnvironmentPostProcessor$JsonPropertyValue (org.springframework.boot.env)
apply:-1, 1671507048 (org.springframework.boot.env.SpringApplicationJsonEnvironmentPostProcessor$$Lambda$41)
accept:193, ReferencePipeline$3$1 (java.util.stream)
tryAdvance:958, Spliterators$ArraySpliterator (java.util)
forEachWithCancel:126, ReferencePipeline (java.util.stream)
copyIntoWithCancel:498, AbstractPipeline (java.util.stream)
copyInto:485, AbstractPipeline (java.util.stream)
wrapAndCopyInto:471, AbstractPipeline (java.util.stream)
evaluateSequential:152, FindOps$FindOp (java.util.stream)
evaluate:234, AbstractPipeline (java.util.stream)
findFirst:464, ReferencePipeline (java.util.stream)
postProcessEnvironment:95, SpringApplicationJsonEnvironmentPostProcessor (org.springframework.boot.env)
onApplicationEnvironmentPreparedEvent:188, ConfigFileApplicationListener (org.springframework.boot.context.config)
onApplicationEvent:176, ConfigFileApplicationListener (org.springframework.boot.context.config)
doInvokeListener:172, SimpleApplicationEventMulticaster (org.springframework.context.event)
invokeListener:165, SimpleApplicationEventMulticaster (org.springframework.context.event)
multicastEvent:139, SimpleApplicationEventMulticaster (org.springframework.context.event)
multicastEvent:127, SimpleApplicationEventMulticaster (org.springframework.context.event)
environmentPrepared:76, EventPublishingRunListener (org.springframework.boot.context.event)
environmentPrepared:53, SpringApplicationRunListeners (org.springframework.boot)
prepareEnvironment:345, SpringApplication (org.springframework.boot)
run:308, SpringApplication (org.springframework.boot)
run:1226, SpringApplication (org.springframework.boot)
run:1215, SpringApplication (org.springframework.boot)
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命名的配置文件。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值