[FIXED] why the @ConfigurationProperties could not read the properties


I want to define a class to read the spring boot application.properties, this is the model class:

package com.dolphin.soa.post.common.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.stereotype.Component;

@ConfigurationProperties(prefix = "dolphin.redis")
public class CruiseRedisKeysConfig {

    private String userSubArticleKey;


and this is the start up class:

public class AppStarter {}

but when I using this configuration, the userSubArticleKey value was null. why could not read the application.properties value? what should I do to fixed this problem? and this is the application.properties:



The Java property userSubArticleKey will be userSubArticleKey or user-sub-article-key in your properties file:



user.sub.article.key means the property key in nested object reachable via article, via nested sub, via nested user.

Answered By – knittl

Answer Checked By – Dawn Plyler (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published