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

公司招人去哪个网站南昌p2p网站专业建设

公司招人去哪个网站,南昌p2p网站专业建设,淘宝城购物中心,免费的wordpress模板下载虽然我们可以通过 Autowired 在 Bean 类中使用自动注入功能#xff0c;但是 Bean 还是在 applicatonContext.xml 文件中通过 bean 进行定义 —— 在前面的例子中#xff0c;我们还是在配置文件中定义 Bean#xff0c;通过 Autowired为 Bean 的成员变量、方法形参或构…虽然我们可以通过 Autowired 在 Bean 类中使用自动注入功能但是 Bean 还是在 applicatonContext.xml 文件中通过 bean 进行定义 —— 在前面的例子中我们还是在配置文件中定义 Bean通过 Autowired为 Bean 的成员变量、方法形参或构造函数形参提供自动注入的功能。 那么能不是也可以通过注解定义 Bean从 XML 配置文件中完全移除 Bean 定义的配置呢 答案是肯定的我们通过 Spring 2.5 提供的 Component 注释就可以达到这个目标了。 修改Bean的java类的代码如下在类名前面加上 Component注解 package com.firemax.test.service; import java.util.ArrayList;import java.util.Iterator;import java.util.List; import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.dom4j.Document;import org.dom4j.DocumentHelper;import org.dom4j.Element;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Component; import com.firemax.test.hibernate.AlcorTCitys;import com.firemax.test.hibernate.AlcorTCitysDAO;import com.firemax.test.hibernate.AlcorTCountries;import com.firemax.test.hibernate.AlcorTCountriesDAO;import com.firemax.test.hibernate.AlcorTProvinces;import com.firemax.test.hibernate.AlcorTProvincesDAO;import com.firemax.test.hibernate.AlcotTDistrict;import com.firemax.test.hibernate.AlcotTDistrictDAO; Componentpublic class CountryService {    private static Log logger  LogFactory.getLog(CountryService.class);    Autowired    private AlcorTCountriesDAO  alcorTCountriesDAO;    Autowired    private AlcorTProvincesDAO  alcorTProvincesDAO;    Autowired    private AlcorTCitysDAO          alcorTCitysDAO;    Autowired    private AlcotTDistrictDAO       alcotTDistrictDAO;        public CountryService(){            }     //这里是业务逻辑的方法     。。。。。}然后我们修改配置文件applicatonContext.xml中启用自动注入的功能而放弃原来的bean方式的配置 ?xml version1.0 encodingUTF-8?beans xmlnshttp://www.springframework.org/schema/beans    xmlns:contexthttp://www.springframework.org/schema/context    xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance    xmlns:txhttp://www.springframework.org/schema/tx    xsi:schemaLocationhttp://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd                                            http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-2.5.xsd                                            http://www.springframework.org/schema/tx  http://www.springframework.org/schema/tx/spring-tx-2.5.xsd    default-autowireautodetect    bean identityManagerFactory        classorg.springframework.orm.jpa.LocalEntityManagerFactoryBean        property namepersistenceUnitName valuetesterPU /    /bean    bean idtransactionManager classorg.springframework.orm.jpa.JpaTransactionManager        property nameentityManagerFactory refentityManagerFactory /    /bean    tx:annotation-driven transaction-managertransactionManager /    bean idtransactionInterceptor        classorg.springframework.transaction.interceptor.TransactionInterceptor        !-- 事务拦截器bean需要依赖注入一个事务管理器 --        property nametransactionManager            ref localtransactionManager /        /property        property nametransactionAttributes            !-- 下面定义事务指service里面的方法传播属性 --            props                prop keyinsert*PROPAGATION_REQUIRED/prop                prop keyupdate*PROPAGATION_REQUIRED/prop                prop keysave*PROPAGATION_REQUIRED/prop                prop keyadd*PROPAGATION_REQUIRED/prop                prop keyupdate*PROPAGATION_REQUIRED/prop                prop keyremove*PROPAGATION_REQUIRED/prop                prop keydelete*PROPAGATION_REQUIRED/prop                prop keyget*PROPAGATION_REQUIRED,readOnly                /prop                prop keyfind*PROPAGATION_REQUIRED,readOnly                /prop                prop keyload*PROPAGATION_REQUIRED,readOnly                /prop                prop keychange*PROPAGATION_REQUIRED/prop                prop keycount*PROPAGATION_REQUIRED/prop                prop key*PROPAGATION_REQUIRED/prop            /props        /property    /bean        !-- 该 BeanPostProcessor 将自动对标注 Autowired 的 Bean 进行注入 --    !--  这个Processor 已经被 context:annotation-config/ 所简化       bean classorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor/    --     !-- context:component-scan/ 配置项不但启用了对类包进行扫描以实施注释驱动 Bean 定义的功能同时还启用了注释驱动自动注入的功能即还隐式地在内部注册了 AutowiredAnnotationBeanPostProcessor 和 CommonAnnotationBeanPostProcessor因此当使用 context:component-scan/ 后就可以将 context:annotation-config/ 移除了。 --    context:component-scan base-package com.firemax/              !-- 定义自动代理BeanNameAutoProxyCreator --    bean idbeanNameAutoProxyCreator        classorg.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator        !-- 指定对满足哪些bean name的bean自动生成业务代理 --        property namebeanNames            list                value*Service/value            /list        /property        !-- 下面定义BeanNameAutoProxyCreator所需的事务拦截器  --        property nameinterceptorNames            list                !-- 此处可增加其他新的Interceptor --                valuetransactionInterceptor/value            /list        /property    /bean    !--     bean idAlcorTCountriesDAO classcom.firemax.test.hibernate.AlcorTCountriesDAO        property nameentityManagerFactory refentityManagerFactory /    /bean    bean idAlcorTProvincesDAO classcom.firemax.test.hibernate.AlcorTProvincesDAO        property nameentityManagerFactory refentityManagerFactory /    /bean    bean idAlcotTDistrictDAO classcom.firemax.test.hibernate.AlcotTDistrictDAO        property nameentityManagerFactory refentityManagerFactory /    /bean    bean idAlcorTCitysDAO classcom.firemax.test.hibernate.AlcorTCitysDAO        property nameentityManagerFactory refentityManagerFactory /    /bean         bean idCountryService classcom.firemax.test.service.CountryService/    --/beans 新的applicaitonContext.xml 配置文件中蓝色的部分就是原来的bean的注入方式现在已经给屏蔽了。不需要再写。而红色部分就是使用了context:component-scan base-package com.firemax/ 让spirng自动搜索然后注入。 注意 这里注入的bean 的名称是按照类的名称把第一个字母改成小写来命名的。比如例子中的CountryService的bean的名称就是countryService.我们也可以通过Component(countryService) 这种方式来显示的定义一个bean的注入名称。但是在大多数情况下没有必要。 context:component-scan/ 的 base-package 属性指定了需要扫描的类包类包及其递归子包中所有的类都会被处理。 context:component-scan/ 还允许定义过滤器将基包下的某些类纳入或排除。Spring 支持以下 4 种类型的过滤方式通过下表说明  扫描过滤方式过滤器类型说明注释假如 com.firemax.test.SomeAnnotation 是一个注释类我们可以将使用该注释的类过滤出来。类名指定通过全限定类名进行过滤如您可以指定将 com.firemax.test.IncludeService纳入扫描而将 com.firemax.test.NotIncludeService 排除在外。正则表达式通过正则表达式定义过滤的类如下所示 com/.firemax/.test/.Default.*AspectJ 表达式通过 AspectJ 表达式定义过滤的类如下所示 com. firemax.test..*Service下面是一个简单的例子 context:component-scan base-packagecom.firemax    context:include-filter typeregex         expressioncom/.firemax/.test/.service/..*/    context:exclude-filter typeaspectj         expressioncom.firemax.test.util..*//context:component-scan 默认情况下通过 Component 定义的 Bean 都是 singleton 的如果需要使用其它作用范围的 Bean可以通过 Scope 注释来达到目标如以下代码所示  通过 Scope 指定 Bean 的作用范围                 package com.firemax.tester.service;import org.springframework.context.annotation.Scope;…Scope(prototype)Component(countryService)public class CountryService{    …} 这样当从 Spring 容器中获取 boss Bean 时每次返回的都是新的实例了。   在Spring2.5中引入了更多的典型化注解Repository ServiceControler是Component的细化。分别表示持久层服务层控制层。建议使用这个注解来取代Component   附上一个java Applicaiton的简单测试程序   /* * Created on 2008-9-28 * * 徐泽宇 roamer */package com.firemax.test.tester; import java.util.Iterator; import org.springframework.context.ApplicationContext;import org.springframework.context.support.FileSystemXmlApplicationContext; import com.firemax.test.hibernate.AlcorTCitys;import com.firemax.test.hibernate.AlcorTCitysDAO;import com.firemax.test.hibernate.AlcorTCountries;import com.firemax.test.hibernate.AlcorTProvinces;import com.firemax.test.hibernate.AlcotTDistrict;import com.firemax.test.hibernate.AlcotTDistrictDAO;import com.firemax.test.service.CountryService; public class Tester {     /**     * param args     */    public static void main(String[] args) throws Exception{        // TODO Auto-generated method stub        ApplicationContext ctx      new FileSystemXmlApplicationContext(/WebContent/WEB-INF/classes/applicationContext*.xml);        String[] beans  ctx.getBeanDefinitionNames();        for (int i  0 ; i  beans.length;i)        {            System.out.println(beans[i]);        }        CountryService countryService (CountryService)ctx.getBean(countryService);              AlcorTCountries  alcorTCountries countryService.getCountriesInfo(CN);        System.out.println(alcorTCountries.getCountry());        System.out.println(开始调用子类);        System.out.println(alcorTCountries.getAlcorTProvinceses().size());        IteratorAlcorTProvinces it  alcorTCountries.getAlcorTProvinceses().iterator();        while (it.hasNext()){            AlcorTProvinces  alcorTProvinces (AlcorTProvinces)it.next();            System.out.println(alcorTProvinces.getProvinceName());        }        AlcotTDistrict alcotTDistrict new AlcotTDistrict();        alcotTDistrict.setDistrictCode(22);        alcotTDistrict.setDistrictName(浦东);        AlcorTCitys alcorTCitys countryService.getCityInfo(021);        alcotTDistrict.setAlcorTCitys(alcorTCitys);        countryService.saveProvinces(alcotTDistrict);            }} 在所有的JPOPO中我们可以使用Entity 这个注解来注入 JOPO。这样我们在 Persistent.xml中就不需要在 定义哪些POJO的类了。  感谢 JPA 感谢Spring 终于不要频繁的去定义和修改这些Bean了       原文网址http://blog.csdn.net/remote_roamer/article/details/3008016 转载于:https://www.cnblogs.com/winkey4986/archive/2012/02/16/2355023.html
http://www.zqtcl.cn/news/903578/

相关文章:

  • 国外mod大型网站财税公司
  • 一个很好的个人网站开发做一个简单网页多少钱
  • 东莞在哪里学网站建设网站建设团队与分工
  • 网站功能插件昆明网站建设技术研发中心
  • 网站开发培训中心 市桥移动端ui
  • 高碑店地区网站建设上海排名十大装潢公司
  • 无锡自助建站网站还是新能源专业好
  • pc 手机网站 微站如何建设与维护网站
  • 大学生兼职网站开发毕设论文杭州网络排名优化
  • 做教育机器网站网站建设的步骤图
  • 桔子建站是什么平台郑州公司注册网上核名
  • 网站开发技能有哪些网站建设艾金手指科杰
  • 网站建设挂什么费用网站建设学那些课
  • 网站定位与功能分析在互联网公司做网站
  • 安阳网站建设兼职做网站推广有哪些公司
  • 网站制作的一般过程怎么用手机搭建网站
  • 备案 网站名称 怎么改深圳建网站公司
  • html 企业网站模板网站策划书免费
  • 网站建设销售ppt拖拽建站系统源码
  • 网站托管费用多少网站的开发流程
  • 周到的商城网站建设北京品牌网站
  • 网站开发费用属于什么科目网站建设考试多选题
  • c asp做网站wordpress4.5.2文章采集
  • 百度网站建设电话建立网站站建设可以吗
  • 网站后台代码在哪修改网站如何做下一页
  • 网站开发职业要求百度推广代理商与总公司的区别
  • 西安网站建设中心网页 网 址网站区别
  • 技术支持东莞网站建设机械seo岗位是什么意思
  • 做商城网站需要备案什么域名硬件开发工具有哪些
  • 网络网站制作技巧wordpress全文