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

自己做套现要建网站吗/电商运营推广

自己做套现要建网站吗,电商运营推广,今日重庆新闻最新头条10条,健康咨询类网站模板2019独角兽企业重金招聘Python工程师标准>>> 在spring容器中配置bean&#xff0c;常用到的元素除了<value>和<ref>外&#xff0c;还有<props>、<list>、<set>、<map>&#xff0c;在hibernate等框架的配置文件中我们经常可以见到…

2019独角兽企业重金招聘Python工程师标准>>> hot3.png


在spring容器中配置bean,常用到的元素除了<value>和<ref>外,还有<props>、<list>、<set>、<map>,在hibernate等框架的配置文件中我们经常可以见到这些元素,下面是他们的具体用法。 

1.<props>元素 
<props>创建了一个注入的java.util.Properties元素。例如每个人都有身高、体重等基本信息 

Java代码   收藏代码
  1. 1 import java.util.Properties;  
  2. 2   
  3. 3 public class Person {  
  4. 4     private Properties basicInfo;  
  5. 5   
  6. 6     public void setBasicInfo(Properties basicInfo) {  
  7. 7         this.basicInfo = basicInfo;  
  8. 8      }  
  9. 9 }  


配置方式: 
Java代码   收藏代码
  1. 1 <bean id="person" class="Person">  
  2. 2         <property name="basicInfo">  
  3. 3             <props>  
  4. 4                 <!-- 身高 -->  
  5. 5                 <prop key="stature">1.75</prop>  
  6. 6                 <!-- 体重 -->  
  7. 7                 <prop key="avoirdupois">120</prop>  
  8. 8             </props>  
  9. 9         </property>  
  10. 10     </bean>  



2.<list>元素 
<list>元素对应于java.util.ArrayList.例如每个人都有一些朋友 
Java代码   收藏代码
  1. 1 package org.hag.flex.model;  
  2. 2   
  3. 3 import java.util.List;  
  4. 4 import java.util.Properties;  
  5. 5   
  6. 6 public class Person {  
  7. 7     private Properties basicInfo;  
  8. 8     private List friends;  
  9. 9   
  10. 10     public void setBasicInfo(Properties basicInfo) {  
  11. 11         this.basicInfo = basicInfo;  
  12. 12      }  
  13. 13   
  14. 14     public void setFriends(List friends) {  
  15. 15         this.friends = friends;  
  16. 16      }  
  17. 17 }  
  18. 18  


配置该person的朋友有小红、姚明和张三 

Java代码   收藏代码
  1. 1 <bean id="yaoming" class="Person">  
  2. 2         <prop key="age">25</prop>  
  3. 3         <prop key="stature">2.26</prop>  
  4. 4         <prop key="avoirdupois">140</prop>  
  5. 5 </bean>  
  6. 6 <bean id="person" class="Person">  
  7. 7         <property name="basicInfo">  
  8. 8             <props>  
  9. 9                 <!-- 身高 -->  
  10. 10                 <prop key="stature">1.75</prop>  
  11. 11                 <!-- 体重 -->  
  12. 12                 <prop key="avoirdupois">120</prop>  
  13. 13             </props>  
  14. 14         </property>  
  15. 15         <property name="firends">  
  16. 16             <list>  
  17. 17                 <value>xiaohong</value>  
  18. 18                 <ref local="yaoming"/>  
  19. 19                 <value>zhangsan</value>  
  20. 20             </list>  
  21. 21         </property>  
  22. 22 </bean>  


3.<set>元素 
<set>元素和<list>元素的用法一样,不同的是他注入的是java.util.Set元素。 
4.<map>元素 
<map>元素用来注入java.util.Map元素。 

Java代码   收藏代码
  1. 1 <property name="score">  
  2. 2             <map>  
  3. 3                 <entry key="math" value="150"></entry>  
  4. 4                 <entry key="english" value="140"></entry>  
  5. 5                 <entry key="chinese" value="60"></entry>  
  6. 6             </map>  
  7. 7 </property>  


4、spring配置里map的value是list配法 
Java代码   收藏代码
  1. <map>  
  2.             <entry key="a">  
  3.                <list>  
  4.                   <ref bean="b"/>  
  5.                   <ref bean="c"/>  
  6.                </list>   
  7.             </entry>  
  8.             <entry key="d">  
  9.                <list>  
  10.                   <ref bean="e"/>  
  11.                </list>  
  12.             </entry>  
  13.  </map>  



4、<!-- 外部配置文件 --> 
Java代码   收藏代码
  1. <!-- 加载jdbc属性文件 -->  
  2. <bean id="propertyConfigurer"  
  3.         class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
  4.     <property name="locations">  
  5.         <list>  
  6.             <value>classpath*:config.properties</value>  
  7.         </list>  
  8.     </property>  
  9. </bean>  
  10.   
  11. <!-- 外部配置文件 -->  
  12. <context:property-placeholder location="classpath*:application.properties" />  
  13.   
  14. <!--定义全局连接命名变量 -->  
  15. <util:properties id="posmqProperties" location="classpath:/jms/pos-mq-jndi.properties" />   


5、查找jndi的方式 
Java代码   收藏代码
  1. <bean id="jmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">  
  2.         <property name="jndiName">  
  3.             <value>java:comp/env/jms/name</value>  
  4.         </property>  
  5. </bean>  


Java代码   收藏代码
  1. <!--  MQ 连接工厂 -->  
  2. <jee:jndi-lookup id="posMqConnectionFactory" jndi-name="jms/posmq" environment-ref="posmqProperties" />  
  3. <!--定义全局连接命名变量 -->  
  4. <util:properties id="posmqProperties" location="classpath:/jms/pos-mq-jndi.properties" />   
  5.   
  6. <!-- Jndi -->   
  7. <bean id="jndiTemplate"   
  8. class="org.springframework.jndi.JndiTemplate">   
  9. <property name="environment">   
  10. <props>   
  11. <prop key="java.naming.factory.initial">   
  12. weblogic.jndi.WLInitialContextFactory   
  13. </prop>   
  14. <prop key="java.naming.provider.url">   
  15. t3://192.166.68.44:7001   
  16. </prop>   
  17. <prop key="java.naming.factory.url.pkgs">   
  18. weblogic.jndi.factories   
  19. </prop>   
  20. </props>   
  21. </property>   
  22. </bean>   
  23.   
  24. <!-- jms sender -->   
  25. <bean id="jmsConnectionFactory"   
  26. class="org.springframework.jndi.JndiObjectFactoryBean">   
  27. <property name="jndiTemplate" ref="jndiTemplate" />   
  28. <property name="jndiName" value="ConnectionFactory" />   
  29. </bean>   
  30. <bean id="jmsQueue"   
  31. class="org.springframework.jndi.JndiObjectFactoryBean">   
  32. <property name="jndiTemplate" ref="jndiTemplate"></property>   
  33. <property name="jndiName" value="Queue"></property>   
  34. </bean>   
  35.   
  36. <!-- jms template -->   
  37. <bean id="jmsTemplate"   
  38. class="org.springframework.jms.core.JmsTemplate">   
  39. <property name="connectionFactory" ref="jmsConnectionFactory"></property>   
  40. <property name="defaultDestination" ref="jmsQueue"></property>   
  41. </bean>  
  


6、Spring 在配置中使用*.properties 
Java代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
  4.     xmlns:context="http://www.springframework.org/schema/context"  
  5.     xmlns:util="http://www.springframework.org/schema/util"  
  6.     xsi:schemaLocation="http://www.springframework.org/schema/beans     
  7.             http://www.springframework.org/schema/beans/spring-beans-3.0.xsd    
  8.             http://www.springframework.org/schema/context    
  9.             http://www.springframework.org/schema/context/spring-context-3.0.xsd  
  10.             http://www.springframework.org/schema/util   
  11.             http://www.springframework.org/schema/util/spring-util-3.0.xsd">  
  12.     <context:annotation-config/>  
  13.     <!-- picks up and registers AppConfig as a bean definition -->  
  14.     <context:component-scan base-package="com.web.spring.other" />  
  15.       
  16.     <bean class="com.web.spring.other.AppConfig"/>  
  17.     访法一  
  18.     <context:property-placeholder location="classpath:jdbc.properties" />  
  19.         方法二  
  20.     <util:properties id="jdbcProperties" location="classpath:jdbc.properties"/>  
  21. </beans>  


Java代码   收藏代码
  1. 实现一:  
  2. package com.web.spring.other;  
  3.   
  4. import org.springframework.beans.factory.annotation.Value;  
  5. import org.springframework.context.annotation.Bean;  
  6. import org.springframework.context.annotation.Configuration;  
  7. import org.springframework.context.annotation.ImportResource;  
  8.   
  9. @Configuration  
  10. @ImportResource("classpath*:spring/spring-properties.xml")  
  11. public class AppConfig {  
  12.     private @Value ("${jdbc.driverClassName}") String driverClassName;  
  13.     @Bean (initMethod = "init")  
  14.     public JDBCBean jdbc(){  
  15.         JDBCBean jdbc=new JDBCBean();  
  16.         jdbc.setDriverClassName(driverClassName);  
  17.         return jdbc;  
  18.     }  
  19.   
  20. }  
  21.   
  22. 实现二:  
  23. package com.web.spring.other;  
  24.   
  25. import org.springframework.beans.factory.annotation.Value;  
  26. import org.springframework.context.annotation.Bean;  
  27. import org.springframework.context.annotation.Configuration;  
  28.   
  29. @Configuration  
  30. public class AppConfig {  
  31.     private @Value ("#{jdbcProperties.driverClassName}") String driverClassName;  
  32.     //private @Value("#{jdbcProperties['jdbc.driverClassName']}") String driverClassName;  
  33.     @Bean (initMethod = "init")  
  34.     public JDBCBean jdbc(){  
  35.         JDBCBean jdbc=new JDBCBean();  
  36.         jdbc.setDriverClassName(driverClassName);  
  37.         return jdbc;  
  38.     }  
  39.   
  40. }  

转载于:https://my.oschina.net/u/1012289/blog/129681

http://www.lbrq.cn/news/1441549.html

相关文章:

  • 做费网站/个人网站怎么建立
  • wordpress的xss漏洞/seo网络优化日常工作内容
  • 2020互联网公司排名/链接优化方法
  • 网站服务器和网站备案/网址怎么创建
  • 成都龙泉工程建设有限公司网站/网页制作代码大全
  • 个人如何建网站/企业网站优化排名
  • 网站开发学习流程图/百度关键词排名点击
  • 网络软文推广网站/seo知名公司
  • 佛山网站建设熊掌号/长沙网站seo外包
  • 网站制作详细报价表/百度搜索关键词技巧
  • 专业网站开发企业/岳阳seo公司
  • 中国制造网国际站/网页设计制作网站模板图片
  • 精准引流推广团队/百度自然排名优化
  • 设计师万能导航网站/免费发帖的网站
  • 优酷 做视频网站还能成功吗/线上营销推广方式都有哪些
  • 企业网站备案域名可以用个人的/网络营销公司招聘
  • 网站名字/站长工具ip地址查询域名
  • 做传单的网站/刺激广告
  • 网页网站建设的ppt/seo网站推广全程实例
  • 景乔网站建设/公司网站建设公司
  • wordpress首页显示最新文章/厦门seo优化推广
  • jsp网站建设教程/小红书seo排名帝搜软件
  • 网站会员注册系统/西安网站建设推广
  • 有哪些网站建设方案/温州seo顾问
  • 做花酒的网站/百度搜索关键词推广
  • 有什么网站可以做/千度搜索引擎
  • 重庆网站建设只选承越/seo优化排名教程百度技术
  • 便利的网站建设/流量平台排名
  • 高端建站是什么意思/百度服务中心
  • 站长之家whois/宁波seo外包哪个品牌好
  • 过程设计工具深度解析-软件工程之详细设计(补充篇)
  • 晓知识: 如何理解反射
  • GraphQL 原理、应用与实践指南
  • 在Colab上复现LoRA相关论文实验的完整指南
  • 华为发布AI推理新技术,降低对HBM内存依赖
  • Redis 01 数据结构