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

seo建站需求做一名网络写手去那个网站好

seo建站需求,做一名网络写手去那个网站好,wordpress上传阿里云,网站建设公司 专题制作spring通过Environment对象来存储上下文环境变量信息#xff0c;即包含当前系统环境变量也包含配置文件配置变量。Environment作为一个bean被存放在容器中#xff0c;可以在需要的地方进行依赖注入直接使用。 Environment的创建 以AnnotationConfigApplicationContext容器类…spring通过Environment对象来存储上下文环境变量信息即包含当前系统环境变量也包含配置文件配置变量。Environment作为一个bean被存放在容器中可以在需要的地方进行依赖注入直接使用。 Environment的创建 以AnnotationConfigApplicationContext容器类来看在其构造函数总会初始化reader new AnnotatedBeanDefinitionReader(this);然后会调用重载构造函数AnnotatedBeanDefinitionReader(registry, getOrCreateEnvironment(registry))最后通过getEnvironment获取environment。 AbstractApplicationContext#getEnvironment public ConfigurableEnvironment getEnvironment() {if (this.environment null) {this.environment createEnvironment();}return this.environment; }protected ConfigurableEnvironment createEnvironment() {return new StandardEnvironment();}这里最后看到创建了一个StandardEnvironment类型的实例。 Environment放入容器 在使用中可以直接通过注解注入的方式将environment注入直接使用如下 Autowired private Environment env;那么environment什么时候装载到容器中成为一个bean的呢 这里还要回到容器初始化的Refresh方法在初始化扫描到的bean前会调用prepareBeanFactory()方法。 AbstractApplicationContext#prepareBeanFactory //... // Register default environment beans. if (!beanFactory.containsLocalBean(ENVIRONMENT_BEAN_NAME)) {beanFactory.registerSingleton(ENVIRONMENT_BEAN_NAME, getEnvironment()); } if (!beanFactory.containsLocalBean(SYSTEM_PROPERTIES_BEAN_NAME)) {beanFactory.registerSingleton(SYSTEM_PROPERTIES_BEAN_NAME, getEnvironment().getSystemProperties()); } if (!beanFactory.containsLocalBean(SYSTEM_ENVIRONMENT_BEAN_NAME)) {beanFactory.registerSingleton(SYSTEM_ENVIRONMENT_BEAN_NAME, getEnvironment().getSystemEnvironment()); } if (!beanFactory.containsLocalBean(APPLICATION_STARTUP_BEAN_NAME)) {beanFactory.registerSingleton(APPLICATION_STARTUP_BEAN_NAME, getApplicationStartup()); }这一步发生在所有的bean实例化之前beanFactory.registerSingleton方法会将当前对象放到容器单例池里。也就是单例bean。可以说上面几个bean是最早一批bean。这里看到有environment、systemProperties、systemEnvironment和applicationStartup。 属性文件加载 在上一篇文章中介绍Configuration时候可以通过PropertySource进行属性配置文件的引入引入的配置文件最终会放入environment中可以通过environment对象获取属性文件内容。 如下 Autowiredprivate Environment env;PostConstructpublic void init(){log.info(property name:{},env.getProperty(name));}那么配置文件是怎么被存放到environment中的呢在上面一步将environment放入spring容器的一步所有的bean都还未实例化PropertySource也未初始化这时候还未加载自定义引入的properties配置文件。 还是上一篇文章说的容器会引入ConfigurationClassPostProcessor类来解析处理Configuration注解该类 不仅是一个bean定义后置处理器还继承了EnvironmentAware接口。这样当ConfigurationClassPostProcessor在被容器实例化的时候initializeBean()方法会调用invokeAwareInterfaces方法这里会调到setEnvironment方法将容器的environment传递给当前ConfigurationClassPostProcessor。这样ConfigurationClassPostProcessor就拥有了容器的environment。 ApplicationContextAwareProcessor#invokeAwareInterfaces private void invokeAwareInterfaces(Object bean) {if (bean instanceof EnvironmentAware) {((EnvironmentAware) bean).setEnvironment(this.applicationContext.getEnvironment());}//... }下一步在ApplicationContextAwareProcessor中会使用ConfigurationClassParser类进行PropertySource的解析将解析到的property追加到environment的propertySources中。 具体逻辑在ConfigurationClassParser#addPropertySource()中。 最后来看下environment内部存储结构吧 {//存储Profileprivate final SetString activeProfiles new LinkedHashSet();private final SetString defaultProfiles new LinkedHashSet(getReservedDefaultProfiles());//内部使用ListPropertySource? propertySourceList来存储多个PropertySourceprivate final MutablePropertySources propertySources;private final ConfigurablePropertyResolver propertyResolver; }Profile怎么理解呢可以理成剖面环境。举例说明就好理解了。 bean可以通过Profile进行修饰例如在数据源datasources初始化时候可以指定不同的Profile。 Profile(dev) ConfigurationProperties(prefixspring.datasource) public DataSource getDuridSource(){return new DruidDataSource(); } Profile(sit) ConfigurationProperties(prefixspring.datasource) public DataSource getDuridSource(){return new DruidDataSource(); }如果一个bean被Profile修饰则只有当只有Profile指定的值在activeProfiles之内bean才会被加载。 profile的取值设定在 AbstractEnvironment#doGetActiveProfiles protected SetString doGetActiveProfiles() {synchronized (this.activeProfiles) {if (this.activeProfiles.isEmpty()) {String profiles doGetActiveProfilesProperty();if (StringUtils.hasText(profiles)) {setActiveProfiles(StringUtils.commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(profiles)));}}return this.activeProfiles;} }protected String doGetActiveProfilesProperty() {return getProperty(ACTIVE_PROFILES_PROPERTY_NAME);}这里ACTIVE_PROFILES_PROPERTY_NAME “spring.profiles.active。可以在启动时候通过-Dspring.profiles.activexx来指定也可以配置到properties文件中。都可以解析的到。
http://www.dnsts.com.cn/news/96829.html

相关文章:

  • 深圳苏州企业网站建设服务公司手机ps抠图软件下载
  • html5做图书馆网站做电影网站要不要收费的
  • 网站手机版制作站长素材免费下载
  • 网站建设杭州滨江大同网站建设哪家好
  • 北京高端网站建设系统聊城职业 网站建设与管理
  • 垂直网站建设规模网站域名多少钱
  • 教育平台网站建设中国交建招标平台
  • 网站建设管理考核办法教育培训公司
  • 网站建设招标评分表襄樊和襄阳是一个地方吗
  • 网站建设中广告法绝对化用语整理怎样制作免费网页
  • 网站代码优化百度推广常州
  • 怎么注册网站账号一个数据库怎么做二个网站
  • 公司网站去哪里做科技论文发表网
  • 国外创意网站设计网站工信部备案流程
  • 莆田中小企业网站制作嘉兴模板开发建站
  • 飞飞cms悠悠电影网站网站后台下载图片
  • 网站管理手册毕业设计网站建设软件项目
  • 做网站费用走什么科目.org做商业网站
  • 紫色网站模板wordpress后门插件
  • 昆山住房城乡建设局网站查询手机兼职平台网站开发
  • 做网站运营是有提成的吗设计方案范文
  • 重庆专业微信网站制作wordpress页面下
  • p2p网站建设公司哪家好做平台的网站有哪些
  • 织梦做网站好不好mysql 网站登录密码
  • 网速测速seo是什么职位简称
  • 网站下载系统如何做系统静态网站被同行使用
  • 做私人彩票网站做网站如何适应分辨率
  • php做的网站怎么调试wordpress扫码付费可见
  • 大兴营销型网站建设wordpress自定义工具栏
  • 自己的网站 做采集怎么做聊城职业 网站建设与管理