Spring 3, Java Configuration and @Resource
Hi all,
This is driving me absolutely nuts and Google has not been my friend. I am using Spring 3 with Java configuration and @Resource. IntelliJ 10.2 keeps reporting "Could not autowire. No beans of '...' type found.". Although when I run the program, Spring does resolve the resource properly. It seems that if resources are defined in XML configuration files, no errors are reported (i.e., no red squigly line under the variable). If I use resources from Java configuration classes, IntelliJ reports an error. I have not been able to find a solution to this problem. At this point I am assuming that I am not defining something properly for IntelliJ to recognize this or the syntax I am using is not correct. Any help or hints would be appreciated. While I know that the program works, I don't want to just live with it and leave this as it is since maintenance programmers will be confused if they see the error reported on this variable. Example code follows.
Regards,
Mike
@Configuration
public class DateConfig {
@Bean
public LocalDate dateTarget() {
new LocalDate(2011, 3, 25);
}
}
---------------------------------------------------------------------
@Configuration
@Import({DateConfig.class})
public class ResourceConfig {
private @Resource LocalDate dateTarget; // <-- This resource definition signaled as unable to autowire.
Please sign in to leave a comment.
This looks like a bug. Could you file it to Youtrack?
Meanwhile you can turn off corresponding inspection.