2014-11-05 27 views
1

我想用一些java源文件创建一个Grails应用程序。这些java文件让我可以通过spring-data-neo4j访问嵌入式Neo4J图形。我会使用Grails Neo4J GORM插件,但事实上,它在Grails 2.3.5以上的版本中不起作用 - 我使用的是2.4.3 - 甚至在使用2.3.5时,当我运行它时,开发人员提供的示例应用程序出现错误)。在Grails中混合java和groovy代码时出错Spring数据应用

我想创建一系列表示图中存在的节点的java类,然后spring-data-neo4j将允许我以Grails的形式访问POJO(如第二个答案的第1点所述在SO here)。我以this Spring Data tutorial here为起点。我已经将Person.java和PersonRepository.java类复制到src/java。然后我运行“grails run-app” - 我不希望发生任何事情,只是为了让Grails编译java源代码然后正常启动(然后我会将Application.java中的一些代码导入到实际使用类的第三个java类)。

不过,我得到了下面的错误和Grails崩溃:

context.ContextLoader Context initialization failed java.lang.NoSuchMethodError: org.springframework.expression.spel.SpelParserConfiguration.(Lorg/springframework/expression/spel/SpelCompilerMode;Ljava/lang/ClassLoader;)V at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) context.GrailsContextLoaderListener Error initializing the application: org.springframework.expression.spel.SpelParserConfiguration.(Lorg/springframework/expression/spel/SpelCompilerMode;Ljava/lang/ClassLoader;)V java.lang.NoSuchMethodError: org.springframework.expression.spel.SpelParserConfiguration.(Lorg/springframework/expression/spel/SpelCompilerMode;Ljava/lang/ClassLoader;)V at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) | Error Forked Grails VM exited with error | Server running. Browse to http://localhost:8080/

如果我运行Java示例应用程序作为一个基本的Java程序(建立并使用“gradle这个运行”运行),那么它的工作原理像广告。

有什么我需要做的,以获得Java代码在Grails弹簧数据应用程序内正确编译?

回答

1

它似乎与相关性的版本不匹配有关。示例代码使用Gradle spring-boot插件来排序传递依赖关系。然而,这不能在我的项目中使用,因为我使用gradle-grails插件,它特别禁止使用Java或Groovy插件(并且Spring启动插件需要Java插件)。

当我改变了依赖从4.1.1(最新的11月6日14),这两个依赖4.0.6,错误走了:

compile "org.springframework:spring-context:4.0.6.RELEASE" 
compile "org.springframework:spring-tx:4.0.6.RELEASE"