I get the following error when I try to unit test my Spring Hibernate DAO classes. This error only comes when I try to deploy the app on tomcat, not when executing the unit tests. When I comment out the test class and test dependencies no error comes.
...Caused by: java.lang.ClassNotFoundException: org.springframework.core.io.Resource...
My Maven dependencies for Spring DAO test as follows: (I am using Spring version 4.0.5.RELEASE)
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework-version}</version>
<optional>true</optional>
</dependency>
My unit test class as follows:
@TransactionConfiguration(defaultRollback = true)
@ContextConfiguration({ "classpath:spring/*.xml" })
@Transactional
@RunWith(SpringJUnit4ClassRunner.class)
public class EmployerDaoHbnTest {
@Inject
EmployerDao employerDao;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
public void testRegisterEmployer() {
assertTrue(employerDao.findEmployer(5) != null);
}
@Test
public void testToString() {
fail("Not yet implemented");
}
}
What dependency am I missing? Where can I officially (such as Spring docs) find that exactly what are the dependencies for Spring DAO test?