Receiving a No bean named 'transactionManager' is defined
1) Here is the Junit4 class(transactionManager has no space between n and s):
@RunWith(SpringJUnit4ClassRunner.class)
@Transactional(propagation=Propagation.REQUIRED)
@ContextConfiguration(locations = { "classpath:resources/Spring-Module.xml" })
@TransactionConfiguration(transactionManager="tran sactionManager", defaultRollback=true)
public class TestApp {
@Autowired
CustomerDAO customerDAO;
@Transactional
@Test
public void testDB() {
Customer customer = new Customer(1, "mkyong", 28);
customerDAO.insert(customer);
Assert.assertEquals("Success", 1, 1);
}
}
2) Below is the Spring configuration
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="dataSource" class="org.springframework.jdbc.datasource.Transac tionAwareDataSourceProxy">
<constructor-arg ref="dataSourceOrg"/>
</bean>
<bean id="dataSourceOrg" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/mkyongjava" />
<property name="username" value="root" />
<property name="password" value="xxxxxx />
</bean>
</beans>


Reply With Quote