Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法自动连线。未找到Neo4jTemplate类型的bean_Java_Spring_Intellij Idea_Spring Data Neo4j - Fatal编程技术网

Java 无法自动连线。未找到Neo4jTemplate类型的bean

Java 无法自动连线。未找到Neo4jTemplate类型的bean,java,spring,intellij-idea,spring-data-neo4j,Java,Spring,Intellij Idea,Spring Data Neo4j,我使用IDEA IntelliJ 12.0.2 我的application-context.xml是: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://w

我使用IDEA IntelliJ 12.0.2

我的application-context.xml是:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd">

    <neo4j:config storeDirectory="../embeddedNeo4j"/>

    <context:spring-configured/>

    <context:annotation-config/>
    <context:component-scan base-package="models"/>

</beans>
我错过了一些配置吗


这似乎是Intellij的一个老问题:

在Intellij和Spring数据bean中经常发生这种情况。IntelliJ不能很好地从Spring数据的命名空间配置中解析出实例。例如(除了您的),IntelliJ将无法正确验证扩展Spring Data
MongoRepository
@Autowired
@Inject
ed类。正如您所注意到的,它不会伤害您的应用程序,但在开发过程中非常烦人。以下是如何抑制“错误”:


通过单击红色灯泡(鼠标悬停在红色下划线元素上时出现错误指示灯),选择“Inspection”Autowiring for Bean Class“options”,然后最后选择“Suppress for field”。或者,如果要为整个类禁用它,请选择“Suppress for Class”

这个问题不清楚您的应用程序是否不工作,或者它只是一个IDE错误,但应用程序按预期工作。@Andrey Polunin确实,应用程序可以编译,但IntelliJ警告此“错误”。
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.neo4j.support.Neo4jTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/application-context.xml"})
@Transactional
public class MyTest {

    @Autowired
    Neo4jTemplate template; //=> Could not autowire.No beans of Neo4jTemplate type found

    //my tests here
}
@SuppressWarnings("SpringJavaAutowiringInspection")
@Autowired
Neo4jTemplate template;