我有一个带有Date的构造函数,但它总是需要启动服务器的日期,我想我需要像make protoype my bean这样的东西。
@Service("calendarioBO")
public class CalendarioBusinessImpl implements CalendarioBusiness{
private final String strFechaHoy;
private final String [] segmentos;
private final int mesHoy;
private final int anioHoy;
private final int mesAnt;
private final int mesSig;
private final int anioAnt;
private final int anioSig;
public CalendarioBusinessImpl(){
strFechaHoy = Fecha.getFechaActual("dd/MM/yyyy");
segmentos = strFechaHoy.split("/");
mesHoy = Integer.parseInt(segmentos[1]);
anioHoy = Integer.parseInt(segmentos[2]);
mesAnt = mesHoy-1 <= 0 ? 12: (mesHoy-1);
mesSig = mesHoy+1 >= 13 ? 1: (mesHoy+1);
anioAnt = mesHoy-1 <= 0 ? (anioHoy - 1): anioHoy;
anioSig = mesHoy+1 >= 13 ?(anioHoy + 1): anioHoy;
}
}
这是我的行动
@Service("calendarioAction")
public class CalendarioAction extends ActionSupport implements Serializable{
private static final Logger LOG = Logger.getLogger(CalendarioAction.class);
@Resource
private CalendarioBusiness calendarioBO;
}
这是我的XML
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<context:component-scan base-package="com.att.prh.business.impl" />
<context:component-scan base-package="com.att.prh.llaveMaestra" />
<context:component-scan base-package="com.att.prh.connection" />
<context:component-scan base-package="com.att.feriavirtual.business.impl" />
<context:component-scan base-package="com.att.campania.business.impl" />
<tx:annotation-driven />