当前位置: 首页 > news >正文

买源码的网站公司官网格式设计

买源码的网站,公司官网格式设计,绵阳网站建设怎么做,网站客户运营小王学习录 前言基于注解存储对象Controller (控制器存储)Service (服务存储)Repository (仓库存储)Component (组件存储)Configuration (配置存储)Bean(方法注解) 前言 上一篇文章中已经介绍了在Spring中存储Bean和取Bean的方法. 而在 Spring 中想要更简单的存储和读取对象的… 小王学习录 前言基于注解存储对象Controller (控制器存储)Service (服务存储)Repository (仓库存储)Component (组件存储)Configuration (配置存储)Bean(方法注解) 前言 上一篇文章中已经介绍了在Spring中存储Bean和取Bean的方法. 而在 Spring 中想要更简单的存储和读取对象的核⼼是使⽤注解. 这篇文章介绍如何基于注解存储对象 基于注解存储对象 基于注解存储对象第一步仍然是先修改spring配置文件. 加入代码 ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:contexthttp://www.springframework.org/schema/contextxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsdcontext:component-scan base-packagecom.annotation/context:component-scan /beans其中代码context:component-scan base-packagecom.annotation/context:component-scan是在注册要扫描的包, spring启动后, 会自动在指定的包(此处是com.annotation)下扫描, 找到加了注解的类, 然后创建Bean对象并存储到spring容器中. 接下来介绍存储Bean对象的注解. 用于存储Bean对象的注解有五大类注解和一个方法注解. 五大类注解分别是: Controller, Service, Repository, Component, Configuration 方法注解: Bean Controller (控制器存储) Controller public class UseController {public void print(){System.out.println(do_useController);} }Service (服务存储) Service public class UseService {public void print(){System.out.println(do_useService);} }Repository (仓库存储) Repository public class UseRepository {public void print(){System.out.println(do_useRepository);} }Component (组件存储) Component public class UseComponent {public void print(){System.out.println(do_useComponent);} } Configuration (配置存储) Configuration public class UseConfiguration {public void print(){System.out.println(do_useConfiguration);} } 在五大类注解中, Controller, Service, Repository, configuration都是Component的子类. 对于五大类注解的Bean对象命名规则, 观察底层实现源码之后发现. 如果类名前两位都是大写, 则Bean对象名与类名一致. 如果类名第一位大写, 第二位小写, 则Bean对象名是类名第一位小写, 其他位不变. Bean(方法注解) Bean要搭配类注解一起使用, 使用 Bean 注解标记的方法将会被Spring容器注册为一个Bean, 并且该Bean的实例将由该方法返回。 Component public class UserBeans {Beanpublic User user1(){User user new User();user.setId(1);user.setName(zhangsan);user.setPassword(lisi);return user;} }User user applicationContext.getBean(user1, User.class);System.out.println(user.getPassword());Bean注解中可以用name或value指定Bean的对象名, 如果没有指定默认对象名默认为方法名. 上面的例子中没有指定对象名, 下面写一个指定对象名的例子. Component public class UserBeans {Bean(name {user0, user})public User user1(){User user new User();user.setId(1);user.setName(zhangsan);user.setPassword(lisi);return user;} }User user applicationContext.getBean(user0, User.class);System.out.println(user.getPassword());上面的这个例子在获取Bean对象时, 可以用user0, 也可以用user, 但是默认的方法名(user1)不能使用.
http://www.pierceye.com/news/375446/

相关文章:

  • 手机商城网站案例高中男女做那个视频网站
  • 凡客诚品网站航天桥网站建设
  • 烟台网站建设力推企汇互联见效付款网站收录大幅度下降
  • 五河网站建设哪家好百度seo优化服务
  • 城乡住房和城乡建设部网站首页wordpress简历
  • 域名注册网站搭建深圳市宝安区建设局网站
  • 手机网站建设价格是多少湖北省建设规划网站
  • 单位建设网站硬件网站建设的规模设想
  • 白云区网站开发广州番禺最新通告
  • 哈密北京网站建设汽车网站推广策划方案
  • 做钢材的都用什么网站新泰房产网
  • 做羞羞的事的视频网站百度热搜榜怎么打开
  • ui怎样做网站青岛网页设计招聘
  • 建设企业网站e路护航官网企业端学校网站建设工作方案
  • 做网站运营经理的要求网站创建知识
  • ec网站域名app开发策划书范文
  • 免费做图网站设计作品发布平台
  • 网站砍价活动怎么做公司网站更新
  • 高要网站建设wordpress比织梦安全吗
  • 闵行网站建设多久能见效果城市建设模拟游戏网站
  • 誉铭摄影网站网页布局设计技术包括
  • 专门做定制化的网站成都网站推广技巧
  • 有啦域名网站怎么做北京织梦网站建设
  • 公司网站后台怎么添加内容asp网站gzip压缩
  • app浏览器源码大全网站广州网站建设 .超凡科技
  • 免费做网站的方法h5手机网站怎么做
  • 郑州营销型网站制作运营随州网站seo诊断
  • 怎么修改网站备案信息外国的网站是什么网站
  • 小企业网站建设多少钱软件免费下载的网站大全
  • 免费承接网站建设公司网站备案资料