Anton Anton - 5 months ago 19
Java Question

Spring - cannot resolve test class in beans.xml

I'm quite new to Spring framework so this question may look dumb a bit

I'm trying to create abstract class

Test.class
in
test.java
package and configure it with Spring
configuration.xml
file. This file is in
test.resources
package and looks like:

<beans>

... schema URLs ...

<bean abstract="true" id="test" class="Test" />

</beans>


Inspection says:


Cannot resolve class 'Test'


Idea politely offers me to create
Test.class
. I agreed and it has been created in
main.java
package. But it's a bit messy. I do not want it to be there.

Code of Test.class:

@RunWith(SpringJUnitClassRunner.class)
@ContextConfiguration(locations = {"/configuration.xml"})
public abstract class Test {

abstract void test();

}


What do I miss?

Answer

It turned that resource folder matters. Initially configuration.xml was created in resources folder of main package, then moved to resources folder of test package. That is the reason of such behavior. After configuration.xml deleting, resources folder remarking and new configuration.xml creating in resources folder of test package issue was resolved.