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

谁能分享个小网站啊2016年网站推广方法

谁能分享个小网站啊,2016年网站推广方法,网站建设的服务怎么样,免费的ppt通用模板PropertySource介绍 PropertySource是Spring框架中的一个注解#xff0c;主要用于Java配置类中#xff0c;用于引入额外的属性文件#xff0c;以便在Spring应用上下文中使用这些属性。 在Spring 3.1引入Java配置后#xff0c;我们可以通过Configuration注解的类和Bean注解…PropertySource介绍 PropertySource是Spring框架中的一个注解主要用于Java配置类中用于引入额外的属性文件以便在Spring应用上下文中使用这些属性。 在Spring 3.1引入Java配置后我们可以通过Configuration注解的类和Bean注解的方法来进行组件扫描和依赖注入配置。但是对于一些外部化配置如数据库连接信息、邮件服务器配置等我们通常会放在properties或yml文件中这时就可以使用PropertySource来加载这些属性文件。 使用示例 Configuration PropertySource(classpath:application.properties) public class AppConfig {Autowiredprivate Environment env;Beanpublic DataSource dataSource() {DriverManagerDataSource dataSource new DriverManagerDataSource();dataSource.setDriverClassName(env.getProperty(jdbc.driverClassName));dataSource.setUrl(env.getProperty(jdbc.url));dataSource.setUsername(env.getProperty(jdbc.username));dataSource.setPassword(env.getProperty(jdbc.password));return dataSource;} } PropertySource源码 Target(ElementType.TYPE) Retention(RetentionPolicy.RUNTIME) Documented Repeatable(PropertySources.class) public interface PropertySource {String name() default ;String[] value();boolean ignoreResourceNotFound() default false;String encoding() default ;Class? extends PropertySourceFactory factory() default PropertySourceFactory.class; } 源代码截图 PropertySource属性介绍 name表示加载的资源的名称如果为空则会根据加载的配置文件自动生成一个名称。value表示加载的资源的路径这个路径可以是类路径也可以是文件路径。ignoreResourceNotFound表示当配置文件未找到时是否忽略文件未找到的错误。默认值为false也就是说当未找到配置文件时Spring启动就会报错。encoding表示解析配置文件使用的字符集编码。factory表示读取对应配置文件的工厂类默认的工厂类是PropertySourceFactory。 PropertySource使用场景 配置文件的加载在 Spring 应用程序中通常需要加载一些配置文件如数据库连接信息、服务器端口等。使用 PropertySource 注解可以方便地加载这些配置文件并将它们注入到 Spring 应用程序上下文中。多环境配置在开发和部署应用程序时可能需要针对不同的环境如开发环境、测试环境、生产环境等进行不同的配置。使用 PropertySource 注解可以方便地加载不同环境的配置文件并根据环境变量或配置文件名来选择加载哪个配置文件。动态配置在某些情况下可能需要在运行时动态地更改配置信息。使用 PropertySource 注解可以方便地加载动态配置文件并将它们注入到 Spring 应用程序上下文中。属性文件的组织在属性文件中可能需要使用前缀来组织属性。使用 PropertySource 注解的 prefix 属性可以指定属性文件中的前缀以便在属性文件中使用前缀来组织属性。 PropertySource测试示例代码 PropertySource配置类 package com.yang.SpringTest.annotation.propertySourceLearn;import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource;/*** p PropertySource配置类/p** author By: chengxuyuanshitang* Package com.yang.SpringTest.annotation.propertySourceLearn* Ceate Time 2024-03-15 17:04*/ Configuration PropertySource(value classpath:propertySourceDemo.properties) public class PropertySourceConfig {}propertySourceDemo.properties whochengxuyuanshitangdoLearn spring PropertySourceTest测试类 package com.yang.SpringTest.annotation.propertySourceLearn;import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.core.env.ConfigurableEnvironment;/*** pPropertySource测试类/p** author By: chengxuyuanshitang* Package com.yang.SpringTest.annotation.propertySourceLearn* Ceate Time 2024-03-15 17:07*/public class PropertySourceTest {public static void main(String[] args) {AnnotationConfigApplicationContext context new AnnotationConfigApplicationContext(PropertySourceConfig.class);ConfigurableEnvironment environment context.getEnvironment();System.out.println(who is ? : environment.getProperty(who));System.out.println(do something ? : environment.getProperty(do));} }运行结果
http://www.pierceye.com/news/16683/

相关文章:

  • 国外单页制作网站模板下载如何入驻亚马逊跨境电商
  • 做线下活动的网站网站怎样做多语言切换
  • 网站如何提高转化率微网站免费注册
  • 如何快捷建企业网站qq营销
  • “网站建设:上海珍岛”定制网站建设公司电话
  • 婺源网站建设青岛市住房和城乡建设局网站
  • 网站移动终端建设网站图片速度
  • 专业网站设计网站学校的二级网站怎么建设
  • 腾讯云如何做网站wordpress 分享 插件
  • 公司网站备案流程网站怎么添加广告代码
  • 宝塔系统怎么建设网站二维码怎么制作
  • 杭州网站优化咨询python做网站教程
  • 主流大型网站开发语言调查浙江建筑公司排名前100
  • 营销型网站有哪些app百度如何给网站做评价
  • 百度手机网站制作武昌做网站哪家专业
  • 南京代做网站制作狠狠做新网站
  • 网站备案分为几种图片设计素材
  • 为什么几年前做的网站视频看不了wordpress多站点是什么
  • 怎么做购物车网站自己怎么做彩票网站吗
  • 怎么建设两个大淘客网站域名访问过程会不会影响网站访问
  • 永康网站网站建设樱桃小丸子网页设计代码
  • 网站宣传流程医药公司网站建设
  • 怎么建设淘宝客网站jquery代码做的网站
  • 海南网站制作织梦网站首页空白
  • 就业服务工作站建设规范信阳seo
  • 合肥网站排名提升网站开发 如何定位
  • 怎样在网站做视频链接免费广告设计制作app
  • 招聘网站可以做劳务派遣吗大连住房和城乡建设网站
  • 购买一个网站需要多少钱?网站主机服务器
  • 网站中留言板怎么做微信公众号管理系统