简体   繁体   中英

What does @Value annotation mean in Constructor depedency injection in Spring?

I have a snippet that looks like this

@Component
public class Inspiration {
        private String lyric =
            "I can keep the door cracked open, to let light through";
        public Inspiration(
            @Value("For all my running, I can understand") String lyric) {
            this.lyric = lyric;
        }
        public String getLyric() {
            return lyric;
        }
        public void setLyric(String lyric) {
            this.lyric = lyric;
        }
}

What does @Value("For all my running, I can understand") mean here, does it represent the default value for parameter lyric?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM