Reputation: 386
My code looks like below:
import org.apache.catalina.core.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public static void main(String args[]) {
ApplicationContext context =
new ClassPathXmlApplicationContext("spring_conf.xml");
}
why i am getting this error ?
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Type mismatch: cannot convert from ClassPathXmlApplicationContext to ApplicationContext
at root.Main.main(Main.java:11)
Anything i am missing or doing wrong?
Upvotes: 2
Views: 3568
Reputation: 159874
Change your first Spring import to:
import org.springframework.context.ApplicationContext
This is the correct interface that ClassPathXmlApplicationContext implements.
Upvotes: 8
Reputation: 1
Here is a simple solution.
Replace import statement org.apache.catalina.core.ApplicationContext;
with the below import statement:
import org.springframework.context.ApplicationContext;
Works for sure, if not Let me know.
Upvotes: 0
Reputation: 21564
The import org.apache.catalina.core.ApplicationContext
is incorrect, it must be
org.springframework.context.ApplicationContext
Upvotes: 5