Julien Allaix
Julien Allaix

Reputation: 21

Spring beans unresolved in IntelliJ

I started a project with IntelliJ that worked well but did something that broke it. Here is my applicationContext.xml file.

<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.xsd">

    <bean class="foo.Bar" />
</beans>

When inspecting the file I get the error

Cannot resolve bean 'foo.Bar'

The same thing happens for all classes I try to put in my spring configuration file. Any clue about that ?

Here are the screenshots :

spring file error : https://drive.google.com/file/d/0BwhIWYS5TjDRaWxjUzhBbDVnNk0/view?usp=sharing

spring facet : https://drive.google.com/file/d/0BwhIWYS5TjDRb1RHbGlCOW9xeTg/view?usp=sharing

I use Maven to import jars and the classes exist in my classpath. But the code assist doesn't give me any tip when I edit the bean class property.

Upvotes: 1

Views: 6376

Answers (2)

Logemann
Logemann

Reputation: 2953

Without a screenshot of IntelliJ its hard to find out, but here is my shortlist:

1) did you configure the IntelliJ Spring facet to include your xml file? To check that, hit F4 while selecting the root of the project tree and see the Facet configuration for Spring. There your xml file must be listed.

2) you really have package "foo" with the Class "Bar.java" under your "sources" folder in IDEA ?

Upvotes: 1

Jason Marsh
Jason Marsh

Reputation: 380

Without full log-trace, I can only make assumption on why this is happening

  1. Did not include required dependencies (JARs)
  2. You have not created foo.Bar class in your classpath

Upvotes: 0

Related Questions