我正在开发一个spring-data-neo4j项目,该项目是由Java开发的,但是为了提高生产率,我想更改为grails。我将以下applicationContext.xml内容复制到grails applicationContext.xml中:
<!--Custom Configuration-->
<context:annotation-config/>
<context:spring-configured/>
<!-- <context:component-scan base-package="com.turingmac">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>-->
<!-- Neo4j configuration (creates Neo4jTemplate) -->
<neo4j:config graphDatabaseService="graphDatabaseService"/>
<bean id="graphDatabaseService" class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase" scope="singleton">
<constructor-arg index="0" value="http://localhost:7474/db/data"/>
</bean>
<neo4j:repositories base-package="com.turingmac.repository"/>
<tx:annotation-driven mode="proxy"/>
但是我得到了这个错误:
ERROR context.GrailsContextLoader - Error executing bootstraps: Error creating bean with name 'org.springframework.data.neo4j.config.Neo4jConfiguration#0': Cannot resolve reference to bean 'graphDatabaseService' while setting bean property 'graphDatabaseService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphDatabaseService' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.data.neo4j.rest.SpringRestGraphDatabase]: Constructor threw exception; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy31 cannot be cast to javax.ws.rs.Produces Message: Error creating bean with name 'org.springframework.data.neo4j.config.Neo4jConfiguration#0': Cannot resolve reference to bean 'graphDatabaseService' while setting bean property 'graphDatabaseService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphDatabaseService' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.data.neo4j.rest.SpringRestGraphDatabase]: Constructor threw exception; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy31 cannot be cast to javax.ws.rs.Produces Caused by BeanInstantiationException: Could not instantiate bean class [org.springframework.data.neo4j.rest.SpringRestGraphDatabase]: Constructor threw exception; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy31 cannot be cast to javax.ws.rs.Produces Caused by ClassCastException: com.sun.proxy.$Proxy31 cannot be cast to javax.ws.rs.Produces
我尝试了很多方法,例如升级springframework版本,添加额外的jar,这是行不通的。
最佳答案
我时不时偶然偶然发现此异常,通常我会删除该文件夹。按照http://jira.grails.org/browse/GRAILS-9952和https://stackoverflow.com/a/15954077/757413的slcache
关于grails - 如何解决该异常;由ClassCastException引起:com.sun.proxy。$ Proxy31无法转换为javax.ws.rs.Produces,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18939426/