栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Could not resolve placeholder ‘project.version‘ in value “${project.version}”

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Could not resolve placeholder ‘project.version‘ in value “${project.version}”

使用版本:
SpringBoot:2.1.18.RELEASE

SpringCloud: Greenwich.SR6

SpringCloud Alibaba: 2.1.2.RELEASE

jasypt-spring-boot-starter:2.1.2

问题说明:

通过jasypt对Nacos中的敏感配置项进行加密处理后,当更新nacos更新配置项时,后台会报错:

java.lang.IllegalArgumentException: Could not resolve placeholder 'project.version' in value "${project.version}"
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:178)
    at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124)
    at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:239)
    at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:210)
    at org.springframework.core.env.AbstractEnvironment.resolveRequiredPlaceholders(AbstractEnvironment.java:575)
    at java.util.Optional.map(Optional.java:215)
    at com.ulisesbocchio.jasyptspringboot.resolver.DefaultPropertyResolver.resolvePropertyValue(DefaultPropertyResolver.java:38)
    at com.ulisesbocchio.jasyptspringboot.resolver.DefaultLazyPropertyResolver.resolvePropertyValue(DefaultLazyPropertyResolver.java:42)
    at com.ulisesbocchio.jasyptspringboot.EncryptablePropertySource.getProperty(EncryptablePropertySource.java:20)
    at com.ulisesbocchio.jasyptspringboot.caching.CachingDelegateEncryptablePropertySource.lambda$getProperty$0(CachingDelegateEncryptablePropertySource.java:34)
    at org.springframework.cache.concurrent.ConcurrentMapCache.lambda$get$0(ConcurrentMapCache.java:146)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
    at org.springframework.cache.concurrent.ConcurrentMapCache.get(ConcurrentMapCache.java:144)
    at com.ulisesbocchio.jasyptspringboot.caching.CachingDelegateEncryptablePropertySource.getProperty(CachingDelegateEncryptablePropertySource.java:34)
    at com.ulisesbocchio.jasyptspringboot.wrapper.EncryptableMapPropertySourceWrapper.getProperty(EncryptableMapPropertySourceWrapper.java:31)
    at org.springframework.cloud.context.refresh.ContextRefresher.extract(ContextRefresher.java:255)
    at org.springframework.cloud.context.refresh.ContextRefresher.extract(ContextRefresher.java:231)
    at org.springframework.cloud.context.refresh.ContextRefresher.refreshEnvironment(ContextRefresher.java:91)
    at org.springframework.cloud.context.refresh.ContextRefresher.refresh(ContextRefresher.java:85)
    at org.springframework.cloud.endpoint.event.RefreshEventListener.handle(RefreshEventListener.java:72)
    at org.springframework.cloud.endpoint.event.RefreshEventListener.onApplicationEvent(RefreshEventListener.java:61)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360)
    at com.alibaba.cloud.nacos.refresh.NacosContextRefresher$1.innerReceive(NacosContextRefresher.java:133)
    at com.alibaba.nacos.api.config.listener.AbstractSharedListener.receiveConfigInfo(AbstractSharedListener.java:38)
    at com.alibaba.nacos.client.config.impl.CacheData$1.run(CacheData.java:203)
    at com.alibaba.nacos.client.config.impl.CacheData.safeNotifyListener(CacheData.java:233)
    at com.alibaba.nacos.client.config.impl.CacheData.checkListenerMd5(CacheData.java:174)
    at com.alibaba.nacos.client.config.impl.ClientWorker$LongPollingRunnable.run(ClientWorker.java:552)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
    at java.util.concurrent.FutureTask.run(FutureTask.java)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
原因分析:

Spring Boot 会加载classpath下的application.properties

而 SpringCloud Alibaba: 2.1.2.RELEASE中 nacos-api:1.2.1和nacos-client:1.2.1中

application.properties里面有 version=${project.version} ;

导致jasypt解析时,找不到值报错。

解决方案:

将SpringCloud Alibaba升级到2.1.4.RELEASE可以解决该问题。升级后nacos-api:1.4.1和nacos-client:1.4.1中去掉了application.properties。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/948576.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号