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.bootgroupId>
            <artifactId>spring-boot-configuration-processorartifactId>
            <optional>trueoptional>
        dependency>

重新编译项目

检验

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

这样就可以了

你可能感兴趣的:(spring-boot踩坑日记,springboot爬坑日记)