1:spring容器中的bean默认是单例模式的,改成非单例模式需要在类上加上@Scope("prototype")
2:加上@Scope("prototype")后,类的引用不可以用@autowired注入了
3:struts2默认是非单例模式。
4:非单例模式中给方法加上synchronized是没有任何作用的,synchronized只对同一对象起作用。
所以不要在struts的anction中给方法加上synchronized限制,因为加和没加是一样的效果。
5:单例模式类A中存在非单例模式类B,C类调用A中的B,出来的结果很可能是单例的。可以用hashcode来看。
@Scope("prototype")
@Service("GjSaleOrderServiceImpl")
public class GjSaleOrderServiceImpl implements IGjSaleOrderService {
其他类引用上面的类
@Resource(name=“GjSaleOrderServiceImpl”)
private GjSaleOrderServiceImpl saleOrderService; 不要用@autowired