3
這是ManagedBean一個ManagedBeanNotSerializableException與ViewScoped和Spring的服務
@ManagedBean @ViewScoped public class DetailItem {
private static final long serialVersionUID = -7647929779133437125L;
@ManagedProperty(value = "#{itemServiceImpl}")
private ItemService servItem;
這是服務
@Service("itemServiceImpl") @Transactional(value = "transactionManagerLocal") public class ItemServiceImpl implements ItemService {
private static final long serialVersionUID = 1L;
@Autowired
@Qualifier("itemDaoImpl")
private ItemDAO dao;
,但是當我試圖訪問到所有使用「DetailItem」的頁面,我有以下例外情況:
java.io.NotSerializableException: org.springframework.dao.support.PersistenceExceptionTranslationInterceptor java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164) java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
要解決我做servItem瞬態並從的applicationContext。但我明白這不是正確的解決方案,我沒有找到其他的。哪種方法可以做到這一點?
我沒有使用sessionscoped或requestscoped的例外。