首先强调一下,此问题不影响程序运行。
报错信息:
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命名的配置文件。