我正在做一个春季项目,我正在编写我的 junit 测试用例以删除我的一些测试数据,但我收到以下错误..
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined
我的 junit 测试如下所示:
public class TestRemoveTestData implements BeanFactoryAware {
static boolean functionReturn;
String user = "xxxx@aol.com.dev";
private BeanFactory beanFactory;
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
}
@Autowired
private SessionFactory sessionFactory;
@Test
@Transactional(readOnly = true, propagation = Propagation.REQUIRED)
public void RemoveEnrollmentRecord()
{
Session mySession = sessionFactory.getCurrentSession();
//
// Get profile record based on email address
//
Profile myProfile = (Profile) mySession.createCriteria(Profile.class)
.add(Restrictions.like("email", user)).uniqueResult();
//
// Start to create a new Enrollment Record with a status of "U"
//
Enrollment newEnrollment = new Enrollment();
newEnrollment.setProfile_id(myProfile.getProfile_id());
newEnrollment.setContact_id(myProfile.getContact_id());
mySession.delete(newEnrollment);
mySession.flush();
}
}