首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > CSS >

用@component的bean id, 在spring配置文件app.context.html中的摘引

2012-07-03 
用@component的bean id, 在spring配置文件app.context.html中的引用@Component@Transactionalpublic class

用@component的bean id, 在spring配置文件app.context.html中的引用
@Component
@Transactional
public class SchedulingTasks {
   
    final Logger logger = Logger.getLogger(SchedulingTasks.class);
   
    @Autowired
    PtlCodeDao ptlCodeDao;
   
}

在spring的配置文件app.context.xml中想引用这个SchedulingTasks,如果像上面的@Component没有后面跟名字的,则bean id 默认为头字母小写schedulingTasks.

@Autowired也可以正常用

===========================
@Component("up.portal.util.SchedulingTasks")
@Transactional
public class SchedulingTasks {
   
    final Logger logger = Logger.getLogger(SchedulingTasks.class);
   
    @Autowired
    PtlCodeDao ptlCodeDao;
   
}

在spring的配置文件app.context.xml中想引用这个SchedulingTasks,如果像上面的@Component后面跟名字"up.portal.util.SchedulingTasks"的,则bean id 为@Component的名字"up.portal.util.SchedulingTasks",如:

<!-- 清除过时的认证码 -->
    <bean id="rmCodeShedule"
    value="timeRemoveCode" />
    <property name="concurrent" value="false" />
    </bean>

热点排行