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

忘记网站后台密码新浪博客怎样上传wordpress

忘记网站后台密码,新浪博客怎样上传wordpress,榆林市工程造价信息网,seo公司赚钱吗一、环境与profile ​ 在3.1版本中#xff0c;Spring引入了bean profile的功能。要使用profile#xff0c;首先要将所有不同的bean定义整理到一个或者多个pofile之中#xff0c;再将应用部署到每个环境时#xff0c;确保对应的profile处于激活状态。 在Java配置中#xf…一、环境与profile ​ 在3.1版本中Spring引入了bean profile的功能。要使用profile首先要将所有不同的bean定义整理到一个或者多个pofile之中再将应用部署到每个环境时确保对应的profile处于激活状态。 在Java配置中可以使用Profile注解来指定某个bean属于哪一个profile。 import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;import javax.sql.DataSource;Configuration public class DevelopmentProfileConfig {Profile(dev)Bean()public DataSource dataSource() {return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).addScript(classpath:schema.sql).addScript(classpath:test-data.sql).build();} }在XML中配置profile ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:chttp://www.springframework.org/schema/cxmlns:phttp://www.springframework.org/schema/pxmlns:utilhttp://www.springframework.org/schema/utilxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/utilhttp://www.springframework.org/schema/util/spring-util.xsdprofiledev/beans或者 ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:chttp://www.springframework.org/schema/cxmlns:phttp://www.springframework.org/schema/pxmlns:utilhttp://www.springframework.org/schema/utilxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/utilhttp://www.springframework.org/schema/util/spring-util.xsdbeans profiledev....../beansbeans profileprof....../beans /beans注意 ​ Spring确定那个profile处于激活状态需要依赖两个独立的属性 spring.profiles.activespring.profiles.default 二、条件化的bean ​ Conditional来源于spring-context包下的一个注解。Conditional中文是条件的意思Conditional注解它的作用是按照一定的条件进行判断满足条件给容器注册bean。 三、处理自动装配的歧义性 1. 自动装配的歧义性 ​ 例如我们创建一个接口和三个实现该接口的类并通过隐式的bean发现和自动装配机制进行注入bean。 // Dessert接口 public interface Dessert {void cook(); }// Cake类 Component public class Cake implements Dessert{private String name 蛋糕;private String description 水果;Overridepublic void cook() {System.out.println(name 加了一些 description);} }// Cookies类 Component public class Cookies implements Dessert{private String name 饼干;private String description 巧克力豆;Overridepublic void cook() {System.out.println(name 加了一些 description);} }// IceCream类 Component public class IceCream implements Dessert{private String name 冰淇淋;private String description 奥利奥碎屑;Overridepublic void cook() {System.out.println(name 加了一些 description);} }// 测试类 Autowired private Dessert dessert;Test public void compactDiscTest() {dessert.cook(); }​ 此时由于 Cake、Cookies 和 IceCream 均为 Dessert自动装配在此时会遇到歧义性导致Spring无法做出选择从而抛出org.springframework.beans.factory.UnsatisfiedDependencyException错误。 2. 进行处理 ​ 当确实发生歧义性的时候Spring提供了多种解决方案来解决遮掩的个问题。包括 将可选bean中的某一个设置为首选primary的bean使用限定符qualifier来帮助Spring将可选的bean的方位缩小到只有一个bean。 1Primary 与Component组合 Component Primary public class Cookies implements Dessert{...... }与Bean方法组合 Configuration public class DessertConfig {BeanPrimarypublic Dessert dessert() {return new IceCream();}}在bean元素中使用 bean idiceCreamclasscom.shiftycat.dessert.IceCreamprimarytrue2Qualifier ​ 在使用Primary来表选首选bean时如果标示了两个及以上的首选bean那么该机制就会失效。为了解决这个问题我们可以使用Qualifier来规定限制条件以缩小满足要求的bean数量。 //方法1 Component Qualifier public class IceCream implements Dessert{...... }//方法2 Autowired Qualifier(iceCream) private Dessert dessert;Test public void compactDiscTest() {dessert.cook(); }当然我们也可以创建自定义的限定符例如 Component Qualifier(clod) public class IceCream implements Dessert{...... }Autowired Qualifier(clod) private Dessert dessert;Test public void compactDiscTest() {dessert.cook(); }在Java配置显式定义bean的时候Qualifier也可以与Bean注解一起使用。但是此时如果有两个bean都使用Qualifier进行标记也会出现错误。例如 Component Qualifier(cold) public class IceCream implements Dessert{private String name 冰淇淋;private String description 奥利奥碎屑;Overridepublic void cook() {System.out.println(name 加了一些 description);} }Component Qualifier(cold) public class Popsicle implements Dessert{private String name 棒冰;private String description 巧克力豆;Overridepublic void cook() {System.out.println(name 加了一些 description);} }同时由于Java不允许在同一个条目上重复出现相同类型的多个注解因此使用多个Qualifier注解编译器会提示错误。 // 编译错误 Component Qualifier(cold) Qualifier(creamy) public class IceCream implements Dessert{...... }因此我们可以使用自定义的限定符注解从而可以更便捷地进行限定。 // 自定义限定注解 Target({ElementType.TYPE, ElementType.CONSTRUCTOR,ElementType.FIELD, ElementType.METHOD}) Retention(RetentionPolicy.RUNTIME) Qualifier public interface Cold { }Target({ElementType.TYPE, ElementType.CONSTRUCTOR,ElementType.FIELD, ElementType.METHOD}) Retention(RetentionPolicy.RUNTIME) Qualifier public interface Creamy { }Target({ElementType.TYPE, ElementType.CONSTRUCTOR,ElementType.FIELD, ElementType.METHOD}) Retention(RetentionPolicy.RUNTIME) Qualifier public interface Fruity { }Component Cold Fruity public class Popsicle implements Dessert{...... }Component Cold Creamy public class IceCream implements Dessert{...... }Autowired Cold Fruity private Dessert dessert;Test public void compactDiscTest() {dessert.cook(); }四、bean的作用域 ​ 在默认情况下Spring应用上下文中所有的bean都是以单例singleton的形式创建的。而Spring定义了多种作用域可以基于这些作用域创建bean包括 单例singleton在整个应用中只创建bean的一个实例。原型prototype每次注入或者通过Spring应用上下文获取的时候都会创建一个新的bean实例。会话Session在Web应用中为每个会话创建一个bean实例。请求Request在Web应用中为每个请求创建一个bean实例。 bean的作用域可以使用Scope或者bean元素中的scope属性进行设置。 Component Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class Cake implements Dessert{...... }bean idcakeclasscom.shiftycat.dessert.Cakescopeprototype在Web应用中例如有一个bean代表用户的购物车此时它的作用域一定是会话作用域。 《Spring实战(第4版)》
http://www.pierceye.com/news/673915/

相关文章:

  • 餐饮行业网站建设风格建网站费用
  • 北京网站建设与维护石家庄做淘宝网站
  • seo网站关键词优化费用linux wordpress 伪静态
  • 朋友做的网站图片不显示不出来的网站空间哪家公司的好
  • 外贸网站建设公司价格最全做暖暖网站
  • 手机网站建设代理商怎么自己开一个网站
  • 国内比较高端的设计网站如何通过html做网站
  • 做一个网站怎么赚钱网站建设方向
  • 岳阳网站建设哪里便宜连云港网站制作
  • 企业网站内容运营方案策划网络运营是什么意思
  • 深圳建网站信科南京医院网站建设
  • 新开最好的传奇网站js 网站跳转
  • 阿里巴巴国际站做2个网站有用网站制作是怎么学的
  • 做的网站图片不显示企业邮箱什么格式
  • 今天重大新闻优化设计答案五年级下册
  • 网站建设市场报价建站哪家好 discuz
  • 没后台的网站怎么做优化中国联通网站备案
  • 金融产品做网站推广网站访问者
  • 安徽省工程建设安全协会网站广州网站设计皆赞乐云践新
  • 成都建设网上商城平台公司深圳网站建设推广优化seo
  • 数据服务网站开发国家重点建设裤网站
  • 做兼职上哪个网站wordpress相册灯箱弹窗
  • 微信编辑器做网站网页设计专业开设院校
  • 网站建设衤金手指谷哥十四wordpress电商主题数据库
  • 网站开发要会英语吗app手机网站设计
  • 青岛海诚互联做网站好吗typo wordpress theme
  • 有关大学生做兼职的网站有哪些网站规划建设方案模板
  • 深圳珠宝网站建设分析报告做电影网站 需要进那些群
  • 哪些网站可以做翻译兼职成都编程培训机构排名前十
  • 网站html有趣代码做暖暖视频网站大全