springboot 踩坑日记——Could not resolve placeholder 'profile.name' in value "${profile.name}"

启动报错:Could not resolve placeholder ‘profile.name’ in value “${profile.name}”

spring.profiles.active=${profile.name} 报错

环境:

开发工具:idea

报错内容

07-30 12:11:39.336 INFO [o.s.c.s.PostProcessorRegistrationDelegate B e a n P o s t P r o c e s s o r C h e c k e r ] − B e a n ′ o r g . s p r i n g f r a m e w o r k . c l o u d . a u t o c o n f i g u r e . C o n f i g u r a t i o n P r o p e r t i e s R e b i n d e r A u t o C o n f i g u r a t i o n ′ o f t y p e [ o r g . s p r i n g f r a m e w o r k . c l o u d . a u t o c o n f i g u r e . C o n f i g u r a t i o n P r o p e r t i e s R e b i n d e r A u t o C o n f i g u r a t i o n BeanPostProcessorChecker] - Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration BeanPostProcessorChecker]Beanorg.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfigurationoftype[org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration E n h a n c e r B y S p r i n g C G L I B EnhancerBySpringCGLIB EnhancerBySpringCGLIB 64 f 8 d 49 b ] i s n o t e l i g i b l e f o r g e t t i n g p r o c e s s e d b y a l l B e a n P o s t P r o c e s s o r s ( f o r e x a m p l e : n o t e l i g i b l e f o r a u t o − p r o x y i n g ) 07 − 3012 : 11 : 40.481 E R R O R [ o r g . s p r i n g f r a m e w o r k . b o o t . S p r i n g A p p l i c a t i o n ] − A p p l i c a t i o n r u n f a i l e d j a v a . l a n g . I l l e g a l A r g u m e n t E x c e p t i o n : C o u l d n o t r e s o l v e p l a c e h o l d e r ′ p r o f i l e . n a m e ′ i n v a l u e " 64f8d49b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 07-30 12:11:40.481 ERROR [org.springframework.boot.SpringApplication] - Application run failed java.lang.IllegalArgumentException: Could not resolve placeholder 'profile.name' in value " 64f8d49b]isnoteligibleforgettingprocessedbyallBeanPostProcessors(forexample:noteligibleforautoproxying)073012:11:40.481ERROR[org.springframework.boot.SpringApplication]Applicationrunfailedjava.lang.IllegalArgumentException:Couldnotresolveplaceholderprofile.nameinvalue"{profile.name}"
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:237)
at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:211)
at org.springframework.core.env.AbstractPropertyResolver.resolveNestedPlaceholders(AbstractPropertyResolver.java:228)
at org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:88)
at org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:62)
at org.springframework.core.env.AbstractEnvironment.getProperty(AbstractEnvironment.java:539)
at org.springframework.core.env.AbstractEnvironment.doGetActiveProfiles(AbstractEnvironment.java:238)
at org.springframework.core.env.AbstractEnvironment.getActiveProfiles(AbstractEnvironment.java:224)
at org.springframework.boot.context.config.ConfigFileApplicationListener L o a d e r . g e t O t h e r A c t i v e P r o f i l e s ( C o n f i g F i l e A p p l i c a t i o n L i s t e n e r . j a v a : 379 ) a t o r g . s p r i n g f r a m e w o r k . b o o t . c o n t e x t . c o n f i g . C o n f i g F i l e A p p l i c a t i o n L i s t e n e r Loader.getOtherActiveProfiles(ConfigFileApplicationListener.java:379) at org.springframework.boot.context.config.ConfigFileApplicationListener Loader.getOtherActiveProfiles(ConfigFileApplicationListener.java:379)atorg.springframework.boot.context.config.ConfigFileApplicationListenerLoader.initializeProfiles(ConfigFileApplicationListener.java:354)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:328)
at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:209)
at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:192)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:179)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:165)
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.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:347)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at cn.rainbowbus.EBusApplication.main(EBusApplication.java:20)
Disconnected from the target VM, address: ‘127.0.0.1:60884’, transport: ‘socket’

Process finished with exit code 1

错误分析

无法读取pom.xml中的profile.name 参数

解决:

方式一: spring.profiles.active=${profile.name}改为spring.profiles.active=dev (不建议使用)

方式二:

在pom.xml

加入依赖:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

重新编译项目

检验

[外链图片转存失败(img-o11cwCUq-1564467915794)(](https://img-blog.csdnimg.cn/20190730142516462.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2l0eXFpbmc=,size_16,color_FFFFFF,t_70)]

这样就可以了

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

刘彦青-Yannis

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值