7
我使用IDEA IntelliJ 12.0.2。無法自動裝配。沒有發現Neo4jTemplate類型的豆
我的應用程序的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>
我的測試類是:
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
}
我錯過了一些配置?
這似乎是一個老問題的IntelliJ:http://www.markvandenbergh.com/archives/260/autowiring-spring-bean-in-intellij/
從應用程序無法正常工作或僅僅是IDE錯誤,但應用程序按預期工作的問題來看,並不清楚。 –
@Andrey Polunin事實上,應用程序編譯,但IntelliJ警告這個「錯誤」。 – Mik378