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

网站开发的数据库设计实体是什么商业软文怎么写

网站开发的数据库设计实体是什么,商业软文怎么写,免费无代码开发平台本地部署,做一个简单的公司网站要多少钱在项目中经常会在容器启动时#xff0c;完成特定的初始化操作#xff0c;如资源文件的加载等。 一 实现的方式有三种#xff1a; 1.使用PostConstruct注解#xff0c;该注解作用于void方法上 2.在配置文件中配置init-method方法 bean idstudent class完成特定的初始化操作如资源文件的加载等。 一 实现的方式有三种 1.使用PostConstruct注解该注解作用于void方法上 2.在配置文件中配置init-method方法 bean idstudent classcom.demo.spring.entity.Student init-methodinit2property namename value景甜/propertyproperty nameage value28/propertyproperty nameschool refschool/property /bean 3.将类实现InitializingBean接口 package com.demo.spring.entity;import javax.annotation.PostConstruct;import org.springframework.beans.factory.InitializingBean; import org.springframework.stereotype.Component;/*** author chenyk* date 2018年5月8日*/ Component(student) public class Student implements InitializingBean{private String name;private int age;private School school;public String getName() {return name;}public void setName(String name) {this.name name;}public int getAge() {return age;}public void setAge(int age) {this.age age;}public School getSchool() {return school;}public void setSchool(School school) {this.school school;}//1.使用postconstrtct注解PostConstructpublic void init(){System.out.println(执行 init方法);}//2.在xml配置文件中配置init-method方法public void init2(){System.out.println(执行init2方法 );}//3.实现InitializingBean接口public void afterPropertiesSet() throws Exception {System.out.println(执行init3方法);}} 执行结果 执行 init方法2018-06-11 10:09:16,195 DEBUG [AbstractAutowireCapableBeanFactory.java:1671] : Invoking afterPropertiesSet() on bean with name student执行init3方法2018-06-11 10:09:36,459 DEBUG [AbstractAutowireCapableBeanFactory.java:1731] : Invoking init method init2 on bean with name student执行init2 方法 二 实现原理 由以上执行结果可知先执行PostConstruct注解的方法然后是实现了InitializingBean接口的afterPropertiesSet方法最后执行在配置文件中配置的init-method方法。至于为什么是这个顺序可以看源码 在 AbstractAutowireCapableBeanFactory 类中 protected Object initializeBean(final String beanName, final Object bean, RootBeanDefinition mbd) {if (System.getSecurityManager() ! null) {AccessController.doPrivileged(new PrivilegedActionObject() {Overridepublic Object run() {invokeAwareMethods(beanName, bean);return null;}}, getAccessControlContext());}else {invokeAwareMethods(beanName, bean);}Object wrappedBean bean;if (mbd null || !mbd.isSynthetic()) {wrappedBean applyBeanPostProcessorsBeforeInitialization(wrappedBean, beanName);}try {       //调用初始化方法invokeInitMethods(beanName, wrappedBean, mbd);}catch (Throwable ex) {throw new BeanCreationException((mbd ! null ? mbd.getResourceDescription() : null),beanName, Invocation of init method failed, ex);}if (mbd null || !mbd.isSynthetic()) {wrappedBean applyBeanPostProcessorsAfterInitialization(wrappedBean, beanName);}return wrappedBean;} 然后进入到 invokeInitMethods 方法中  protected void invokeInitMethods(String beanName, final Object bean, RootBeanDefinition mbd)throws Throwable {boolean isInitializingBean (bean instanceof InitializingBean);if (isInitializingBean (mbd null || !mbd.isExternallyManagedInitMethod(afterPropertiesSet))) {if (logger.isDebugEnabled()) {logger.debug(Invoking afterPropertiesSet() on bean with name beanName );}if (System.getSecurityManager() ! null) {try {AccessController.doPrivileged(new PrivilegedExceptionActionObject() {Overridepublic Object run() throws Exception {((InitializingBean) bean).afterPropertiesSet();return null;}}, getAccessControlContext());}catch (PrivilegedActionException pae) {throw pae.getException();}}else {          //直接调用 InitializingBean 接口中的 afterPropertiesSet 方法((InitializingBean) bean).afterPropertiesSet();}}if (mbd ! null) {String initMethodName mbd.getInitMethodName();if (initMethodName ! null !(isInitializingBean afterPropertiesSet.equals(initMethodName)) !mbd.isExternallyManagedInitMethod(initMethodName)) {          //进入该方法可知通过反射的方式调用init-method方法invokeCustomInitMethod(beanName, bean, mbd);}}} 所以初始化方法的执行顺序 afterPropertiesSet() init-method() 博客园的第一篇文章。感觉博客园很干净文章排版特别是插入代码格式看起来很舒服。就不吐槽csdn了。转载于:https://www.cnblogs.com/51life/p/9166009.html
http://wiki.neutronadmin.com/news/198230/

相关文章:

  • 沙坪坝集团网站建设2023中关村手机排行榜
  • 门户网站定制wordpress文件上传系统
  • 西安东郊网站建设德阳网站建设推广
  • 开题报告旅游网站建设做鞋子出口需要作网站吗
  • 泸州市往建局建设银行网站名称印发网站建设方案
  • 广州建设工程安全质量监督网站电商网站建设思路
  • 微信公众号可以做微网站山西建设执业注册管理中心网站
  • 保定集团网站建设双桥区网站制作
  • 好的模板网站推荐百度账号申诉
  • 网站前期运营策略福建最大的网络公司排名
  • 网站代理 正规备案全景效果图网站
  • cdr做网站怎么导出设计制作建筑模型综合实践教案
  • 网站开发前后端分离是主流吗做网站公司实力排名
  • 什么样的网站空间做电影网站不卡建网站商城有哪些公司
  • 沈阳工务建设集团网站怎么样自学做网站
  • 网站规划与网页设计wordpress外网ip访问不了
  • 网站想做个链接怎么做的大港建站公司
  • 网站开发流程的三个部分网站开发常用的开发工具
  • wordpress安装532windows11优化大师
  • 新手seo网站做什么类型好sq网站推广
  • 北京seo网站优化培训附近电脑培训速成班一个月
  • 一流的常州做网站国家住建网查企业资质
  • 网站seo关键词优化排名网络工程师培训班要多少钱
  • 网站建设前 沟通内容新网站seo方法
  • 阿里云centos7做网站wordpress 抓取时间长
  • 广州建设集团网站网络推广和竞价推广有什么区别
  • 咸宁有做网站的吗网站被惩罚
  • 租外国服务器做的网站要备案吗wordpress文本编辑
  • 网站开发大概要多少钱集团网站建设方案
  • 广东建设工程网站早期做的网站支持现在的网速吗