简体   繁体   中英

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.

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 ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM