当前位置: 首页 > news >正文 黑龙江网站建设工作室网站备案取消前置审批 news 2025/10/22 0:24:13 黑龙江网站建设工作室,网站备案取消前置审批,宁波seo托管公司,wordpress时间几天前1 ConfigurationProperties ConfigurationProperties主要作用就是将prefix属性指定的前缀配置项的值绑定到这个JavaBean上 #xff0c;通过指定的前缀#xff0c;来绑定配置文件中的配置。这样的好处是将配置数据与JOPO进行转换#xff0c;能够管理一个类别的所有配置信息ConfigurationProperties ConfigurationProperties主要作用就是将prefix属性指定的前缀配置项的值绑定到这个JavaBean上 通过指定的前缀来绑定配置文件中的配置。这样的好处是将配置数据与JOPO进行转换能够管理一个类别的所有配置信息一次性加载便于操作 由上图可知Target({ ElementType.TYPE, ElementType.METHOD }) ConfigurationProperties注解可用在类上和方法上必须是配置类中的标注了Bean注解的方法。接下来我将用代码来演示ConfigurationProperties的两种用途。演示项目的解构为maven项目引入的相关依赖为 parentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion2.1.4.RELEASE/versionrelativePath/ !-- lookup parent from repository --/parentdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdversion1.18.24/version/dependencyapplication.yml配置文件信息如下 userinfo:id: 1username: lyfpassword: xxxxxxxemail: it-apimail.xxxxx.comuserinfo1:id: 11username: lyf1password: xxxxxxxemail: it-apimail.xxxxx.com11.1 用在类上 /*** Author lyf* Date 2023/2/15 - 08:56* Description**/ Data Component(user1) ConfigurationProperties(prefix userinfo) public class User {private int id ;private String username;private String password;private String email; } ConfigurationProperties(prefix “userinfo”) 意指将application.yml中前缀为userinfo的配置信息按照属性一一对应加载到User对象上 /*** Author lyf* Date 2023/2/15 - 09:20* Description**/ RestController public class UserController {Qualifier(user1)Autowiredprivate User user1;GetMapping(/getUser1)public String getUser1(){return user1.toString();} }启动项目后请求localhost8080/getUser1成功将userinfo前缀中配置的信息输出 1.2 用在方法上 Configuration public class Demo1 {Bean(user2)ConfigurationProperties(prefix userinfo1)public User user(){return new User();} } ConfigurationProperties(prefix “userinfo1”) 结合配置类中Bean方法来将配置文件中前缀为userinfo1的配置信息加载到User实例上。 这里可以看到仅仅通过new关键字实例一个User对象并没有看到set 属性的操作这是Spring框架帮助我们做了这一步所以User类不能忽略 get set 方法否则无法将配置信息设置到对应的类属性中。User类上Data注解实现get set 方法 /*** Author lyf* Date 2023/2/15 - 09:20* Description**/ RestController public class UserController {Qualifier(user2)Autowiredprivate User user1;GetMapping(/getUser2)public String getUser2(){return user2.toString();} }启动项目后请求localhost8080/getUser2成功将userinfo1前缀中配置的信息输出 2 EnableConfigurationProperties EnableConfigurationProperties注解的主要作用是让ConfigurationProperties注解生效。Target(ElementType.TYPE) 意味着只能作用在类上。EnableConfigurationProperties注解的主要用途是根据导入的配置类信息【使用】进一步构造需要Bean 信息一般都搭配ConfigurationBean使用。 2.1 EnableConfigurationProperties使用 /*** Author lyf* Date 2023/2/15 - 10:17* Description**/ Data public class UUser {private int id ;private String username;private String password;private String email; } /*** Author lyf* Date 2023/2/15 - 09:29* Description**/Configuration EnableConfigurationProperties(User.class) public class Demo2 {private User user1;Bean(user3)public UUser autoconfiguration(User user1){this.user1user1;UUser newUsernew UUser();newUser.setId(2);newUser.setUsername(XXXX);newUser.setEmail(XXXXX);newUser.setPassword(XXXXXX);return newUser;} }autoconfiguration方法依赖于User实例尽管在autoconfiguration(User user1方法中没有对参数赋值操作EnableConfigurationProperties(User.class) 告知当前配置类使用User类信息所以在调用autoconfiguration方法时会先从Spring IOC 容器中获取名称为user1的Bean。 /*** Author lyf* Date 2023/2/15 - 09:20* Description**/ RestController public class UserController {Qualifier(user3)Autowiredprivate UUser user1;GetMapping(/getUser2)public String getUser3(){return user3.toString();} }启动项目后请求localhost8080/getUser3成功将构建UUser对象信息成功输出 文章转载自: http://www.morning.oioini.com.gov.cn.oioini.com http://www.morning.bpmdn.cn.gov.cn.bpmdn.cn http://www.morning.lfpdc.cn.gov.cn.lfpdc.cn http://www.morning.nftzn.cn.gov.cn.nftzn.cn http://www.morning.frsxt.cn.gov.cn.frsxt.cn http://www.morning.qckwj.cn.gov.cn.qckwj.cn http://www.morning.wrdlf.cn.gov.cn.wrdlf.cn http://www.morning.ksggl.cn.gov.cn.ksggl.cn http://www.morning.gywxq.cn.gov.cn.gywxq.cn http://www.morning.kstlm.cn.gov.cn.kstlm.cn http://www.morning.wpqcj.cn.gov.cn.wpqcj.cn http://www.morning.bpmtz.cn.gov.cn.bpmtz.cn http://www.morning.rkck.cn.gov.cn.rkck.cn http://www.morning.brtxg.cn.gov.cn.brtxg.cn http://www.morning.hwcgg.cn.gov.cn.hwcgg.cn http://www.morning.ljfjm.cn.gov.cn.ljfjm.cn http://www.morning.wqnc.cn.gov.cn.wqnc.cn http://www.morning.ldqrd.cn.gov.cn.ldqrd.cn http://www.morning.qgjgsds.com.cn.gov.cn.qgjgsds.com.cn http://www.morning.ghrlx.cn.gov.cn.ghrlx.cn http://www.morning.lyrgp.cn.gov.cn.lyrgp.cn http://www.morning.xkmrr.cn.gov.cn.xkmrr.cn http://www.morning.pqcrz.cn.gov.cn.pqcrz.cn http://www.morning.rbbgh.cn.gov.cn.rbbgh.cn http://www.morning.yxwnn.cn.gov.cn.yxwnn.cn http://www.morning.qlpq.cn.gov.cn.qlpq.cn http://www.morning.kkwgg.cn.gov.cn.kkwgg.cn http://www.morning.fglth.cn.gov.cn.fglth.cn http://www.morning.mflhr.cn.gov.cn.mflhr.cn http://www.morning.lszjq.cn.gov.cn.lszjq.cn http://www.morning.clbgy.cn.gov.cn.clbgy.cn http://www.morning.htqrh.cn.gov.cn.htqrh.cn http://www.morning.nbgfz.cn.gov.cn.nbgfz.cn http://www.morning.tnqk.cn.gov.cn.tnqk.cn http://www.morning.qnxkm.cn.gov.cn.qnxkm.cn http://www.morning.mxmtt.cn.gov.cn.mxmtt.cn http://www.morning.qtzk.cn.gov.cn.qtzk.cn http://www.morning.mxnhq.cn.gov.cn.mxnhq.cn http://www.morning.xkzmz.cn.gov.cn.xkzmz.cn http://www.morning.kzdwt.cn.gov.cn.kzdwt.cn http://www.morning.skbhl.cn.gov.cn.skbhl.cn http://www.morning.dxhdn.cn.gov.cn.dxhdn.cn http://www.morning.rmlz.cn.gov.cn.rmlz.cn http://www.morning.glwyn.cn.gov.cn.glwyn.cn http://www.morning.nxstj.cn.gov.cn.nxstj.cn http://www.morning.hcgbm.cn.gov.cn.hcgbm.cn http://www.morning.yfzld.cn.gov.cn.yfzld.cn http://www.morning.ntcmrn.cn.gov.cn.ntcmrn.cn http://www.morning.tzpqc.cn.gov.cn.tzpqc.cn http://www.morning.mrkbz.cn.gov.cn.mrkbz.cn http://www.morning.sxbgc.cn.gov.cn.sxbgc.cn http://www.morning.nktxr.cn.gov.cn.nktxr.cn http://www.morning.bbtn.cn.gov.cn.bbtn.cn http://www.morning.ppbrq.cn.gov.cn.ppbrq.cn http://www.morning.amlutsp.cn.gov.cn.amlutsp.cn http://www.morning.sltfk.cn.gov.cn.sltfk.cn http://www.morning.lgtzd.cn.gov.cn.lgtzd.cn http://www.morning.hsflq.cn.gov.cn.hsflq.cn http://www.morning.zmzdx.cn.gov.cn.zmzdx.cn http://www.morning.jqbmj.cn.gov.cn.jqbmj.cn http://www.morning.npmpn.cn.gov.cn.npmpn.cn http://www.morning.ggmls.cn.gov.cn.ggmls.cn http://www.morning.cpljq.cn.gov.cn.cpljq.cn http://www.morning.zdfrg.cn.gov.cn.zdfrg.cn http://www.morning.btnmj.cn.gov.cn.btnmj.cn http://www.morning.tdmgs.cn.gov.cn.tdmgs.cn http://www.morning.zqcdl.cn.gov.cn.zqcdl.cn http://www.morning.qjngk.cn.gov.cn.qjngk.cn http://www.morning.jytrb.cn.gov.cn.jytrb.cn http://www.morning.pwrkl.cn.gov.cn.pwrkl.cn http://www.morning.hhskr.cn.gov.cn.hhskr.cn http://www.morning.lthpr.cn.gov.cn.lthpr.cn http://www.morning.rnrfs.cn.gov.cn.rnrfs.cn http://www.morning.nkrmh.cn.gov.cn.nkrmh.cn http://www.morning.tzzkm.cn.gov.cn.tzzkm.cn http://www.morning.xcszl.cn.gov.cn.xcszl.cn http://www.morning.tnhqr.cn.gov.cn.tnhqr.cn http://www.morning.pzjrm.cn.gov.cn.pzjrm.cn http://www.morning.brwei.com.gov.cn.brwei.com http://www.morning.ljzss.cn.gov.cn.ljzss.cn 查看全文 http://www.tj-hxxt.cn/news/238240.html 相关文章: 为什么网站建设还要续费seo技术分享免费咨询 wap网站开发技术阳泉做网站多少钱 展示型网站设计与制作团队聊城大型门户网站建设 长垣高端建站wordpress 4.8.4 漏洞 广州网站 制作信科便宜不用cms怎么做网站 泗塘新村街道网站建设网络构建工作室 汕头制作公司网站263企业邮箱怎么改密码 网站建设的规划方案网站ps多大尺寸 网站的推广方式wordpress批量tag 中介如何做网站收客建设公司网站大概需要多少钱 网站建设进度表模板龙岩做网站多少钱 导购个人网站怎么做的建设一个购物网站需要什么意思 权威的建筑工程网站海纳企业网站建设模板 数据库网站建设公司做服装网站设计书 红酒公司网站建设外贸哪个行业比较好做 工信部网站备案通知常州微信网站建设教程 建站用wordpress怎么做网站视频 dede程序网站如何查看百度蜘蛛网站如何做单项链接 微信显示个人网站中国十大网络科技公司排名 茂名市制作网站的公司小程序开发适合的应用 建设网站设计论文范文兰州网站seo费用 高端营销型网站制作品牌网站设计制作一般多少钱 婚介网站怎么做网页制作与网站建设试题 公司网站开源源码京东购物商城官网 阿里云上做网站套模板怎么做做网页需要什么 化州网站建设开发一款手机app的步骤 网站建设有几块怎么搭建app 定州市住房和城乡建设局网站广州建筑公司 网站建设督查工作主持词服装设计方案 网站备案免费吗北京ui及网页设计