在SBT

2014-01-11 67 views
5

使用Spring-數據Neo4j的先進的地圖模式,我想用彈簧數據的Neo4j的advanced mapping mode在我的斯卡拉SBT項目(hosted on github):在SBT

我可以存儲節點與數據庫存儲庫,但我無法進行aspectj-weaving工作。

這是我到目前爲止有:

build.sbt:

resolvers ++= Seq(
    "spring" at "http://repo.spring.io/milestone", 
    "neo4j-releases" at "http://m2.neo4j.org/releases/" 
) 

libraryDependencies ++= Seq(
    "org.springframework.data" % "spring-data-neo4j"   % "3.0.0.M1"  % "compile", 
    "org.springframework.data" % "spring-data-neo4j-aspects" % "3.0.0.M1"  % "compile", 
    "javax.persistence"  % "persistence-api"   % "1.0"   % "compile", 
    "javax.validation"   % "validation-api"   % "1.0.0.GA"  % "compile", 
    "junit"     % "junit"      % "4.11"   % "test", 
    "com.novocode"    % "junit-interface"   % "0.9"   % "test", 
    "org.springframework"  % "spring-test"    % "4.0.0.RELEASE" % "test" 
) 


Seq(aspectjSettings: _*) 

verbose in Aspectj := false 

showWeaveInfo in Aspectj := false 

inputs in Aspectj <+= compiledClasses 

binaries in Aspectj <++= update map { report:UpdateReport => 
    report.matching(
    moduleFilter(organization = "org.springframework.data", name = "spring-data-neo4j-aspects") 
) 
} 

products in Compile <<= products in Aspectj 

products in Runtime <<= products in Compile 

項目/ plugins.sbt:

addSbtPlugin("com.typesafe.sbt" % "sbt-aspectj" % "0.9.4") 

Node類和資源庫:

@NodeEntity 
class Node { 
    @GraphId 
    private var graphId: java.lang.Long = _ 
} 

trait NodeRepository extends GraphRepository[Node] 

測試:

@ContextConfiguration(locations = Array("classpath*:/META-INF/spring/module-context.xml")) 
@RunWith(classOf[SpringJUnit4ClassRunner]) 
class SDNTest extends AbstractJUnit4SpringContextTests { 
    @Autowired private var nodeRepository: NodeRepository = null 

    @Test 
    def persist { 
    val node = new Node() 
    //nodeRepository.save(node) 
    node.persist() 
    } 

} 

當我嘗試運行測試,我得到這些錯誤:

$ sbt test 

[info] Weaving 1 input with 1 AspectJ binary to target/scala-2.10/aspectj/classes... 
[error] error at sdntest/Node.scala::0 The type sdntest.Node must implement the inherited abstract method org.springframework.data.neo4j.aspects.core.GraphBacked.setPersistentState(Ljava/lang/Object;) 
[error]  see also: org/springframework/data/neo4j/aspects/core/GraphBacked.java::0 
[error]  see also: org/springframework/data/neo4j/aspects/support/node/Neo4jNodeBacking.aj:66::0 
[error] error at sdntest/Node.scala::0 The type sdntest.Node must implement the inherited abstract method org.springframework.data.neo4j.mapping.ManagedEntity.setPersistentState(Ljava/lang/Object;) 
[error]  see also: org/springframework/data/neo4j/mapping/ManagedEntity.java::0 
[error]  see also: org/springframework/data/neo4j/aspects/support/node/Neo4jNodeBacking.aj:66::0 
[warn] warning at /home/felix/.ivy2/cache/org.springframework.data/spring-data-neo4j-aspects/jars/spring-data-neo4j-aspects-3.0.0.M1.jar!org/springframework/data/neo4j/aspects/support/relationship/Neo4jRelationshipBacking.class:64::0 advice defined in org.springframework.data.neo4j.aspects.support.relationship.Neo4jRelationshipBacking has not been applied [Xlint:adviceDidNotMatch] 
[warn] warning at /home/felix/.ivy2/cache/org.springframework.data/spring-data-neo4j-aspects/jars/spring-data-neo4j-aspects-3.0.0.M1.jar!org/springframework/data/neo4j/aspects/support/relationship/Neo4jRelationshipBacking.class:167::0 advice defined in org.springframework.data.neo4j.aspects.support.relationship.Neo4jRelationshipBacking has not been applied [Xlint:adviceDidNotMatch] 
[warn] warning at /home/felix/.ivy2/cache/org.springframework.data/spring-data-neo4j-aspects/jars/spring-data-neo4j-aspects-3.0.0.M1.jar!org/springframework/data/neo4j/aspects/support/relationship/Neo4jRelationshipBacking.class:174::0 advice defined in org.springframework.data.neo4j.aspects.support.relationship.Neo4jRelationshipBacking has not been applied [Xlint:adviceDidNotMatch] 
org.aspectj.bridge.AbortException: AspectJ failed 
    at com.typesafe.sbt.SbtAspectj$Ajc$.runAjcMain(SbtAspectj.scala:220) 
... 

我在做什麼錯?

+0

我'git clone'd這個項目,但是當'sbt test'我結束了'sbt.ResolveException:無法解析的依賴:org.neo4j#neo4j-cypher-dsl; 2.0.0-M06:not found'。你在哪裏找到它? –

+0

的確,neo4j-resolver失蹤了。我只是推動了修復。 – man

回答

0

如果你碰到了SBT版本0.13.2現在它工作:

項目/ build.properties - >

sbt.version=0.13.2 

我的猜測是一些關於AspectJ的插件中老年不起作用sbt builds。

+0

我收到了和以前一樣的錯誤。考試通過了嗎? – man

+0

是的。你可能需要清理〜/ .sbt/boot或〜/ .ivy2 /。不知道系統中發生了什麼。 – jsuereth

+0

仍然無法正常工作......我刪除了〜/ .sbt,〜/ .ivy2,並使sbt變得乾淨和乾淨。你使用和我一樣的代碼嗎? (只是推到https://github.com/fdietze/spring-data-neo4j-aspects-sbt-example/tree/sbt132)。從我的理解來看,它並沒有工作得更早,因爲ajc無法編譯Scala本身,而spring-data-neo4j不能編織只有類文件。那麼會發生什麼變化? – man