Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring boot application fails to run because of bean naming violation

I am getting this error :

APPLICATION FAILED TO START
***************************

Description:

Configuration property name 'appConfig.baseVersion' is not valid:

    Invalid characters: 'C'
    Bean: paymentCheckoutRequestBuilder
    Reason: Canonical names should be kebab-case ('-' separated), lowercase alpha-numeric characters and must start with a letter

Action:

Modify 'appConfig.baseVersion' so that it conforms to the canonical names requirements.

paymentCheckoutRequestBuilder is a bean of class PaymentCheckoutRequestBuilder. How am I supposed to fix this , you cannot name a class in kebab-case.

Also, this error occurred after I tried upgrading my spring-boot to 2.2.0.

And what is this appConfig.baseVersion , not able to find anything online.

like image 251
lakhansoren Avatar asked Nov 07 '19 13:11

lakhansoren


3 Answers

this is self explanatory: Reason: Canonical names should be kebab-case Pay attention, that @ConfigurationProperties should not be in camel-case. So you should fix prefix on @ConfigurationProperties for your target bean.

like image 134
Visel_chak Avatar answered Sep 19 '22 10:09

Visel_chak


property appConfig.baseVersion is in camel case so you should use use prefix in configuration as shown below

     mqConfig:
         enable: false
     

then your Configuration file must have @ConfigurationProperties(prefix = "mq-config")

For current example the application.yaml should be

appConfig:
   baseVersion: 1

And java class should be

@Configuration
@ConfigurationProperties(prefix = "app-config")
public class TestConfig {
  int baseVersion;
 }

And the

like image 38
recursion Avatar answered Sep 20 '22 10:09

recursion


I figured it out. For a long time I thought the problem was with paymentCheckoutRequestBuilder. The real problem was with appConfig.baseVersion which is defined as prefix in one of @ConfigurationProperties annotated class. I changed the name and it worked.

like image 32
lakhansoren Avatar answered Sep 20 '22 10:09

lakhansoren