component-scan problem in Eclipse project
I'm trying to test a service that uses an aspect to manage a necessary connection.
The aspect handles creating a pool, opening the connection, etc. It's working when the webapp war is deployed. It's not working in a simple unit test I've written.
The test is something very close to this:
Code:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/test.xml")
public class GatewayTest {
@Autowired
GatewayImpl gatewayImpl;
@Test
public void testConnection() throws Exception {
assertNotNull(gatewayImpl.getManagedConnection());
...
Running the test, I get a BeanCreationException, on that @Autowired annotation at the GatewayImpl.
I have this in test.xml:
<context:component-scan base-package="com.example" />
In this Eclipse project, there are multiple source directories, including src/test/java/com/example and src/main/java/com/example.
The GatewayImpl I need for the test is in src/main, not src/test. src/test doesn't even have a GatewayImpl.
Anyone have any idea how to resolve this?
Thanks,
Colin