专栏名称: 方志朋
号主为CSDN博客之星,博客访问量突破一千万,著有畅销书《深入理解SpringCloud与微服务构建》。主要分享Java、后端架构等技术,用大厂程序员的视角来探讨技术进阶、面试指南、职业规划等。15W技术人的选择!
今天看啥  ›  专栏  ›  方志朋

SpringBoot注入数据的方式

方志朋  · 公众号  · 程序员  · 2020-02-07 22:59

文章预览

点击上方“ 方志朋 ”,选择“ 设为星标 ” 回复” 666 “获取新整理的面试资料 作者:胖先森 juejin.im/post/5c1f119ee51d4568f03b8857 关于注入数据说明 1.不通过配置文件注入数据 通过@Value将外部的值动态注入到Bean中,使用的情况有: 注入普通字符串 注入操作系统属性 注入表达式结果 注入其他Bean属性:注入Student对象的属性name 注入文件资源 注入URL资源 辅助代码 package  com.hannpang.model; import  org.springframework.beans.factory. annotation .Value; import  org.springframework.stereotype.Component; @Component(value =  "st" ) //对student进行实例化操作 public   class   Student   {      @Value( "悟空" )      private  String name;      public  String getName() {          return  name;     }      public  void setName(Str ………………………………

原文地址:访问原文地址
快照地址: 访问文章快照
总结与预览地址:访问总结与预览