- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我在 PersistenceContext.java 中的代码
package yuzhaoLiu.project.testNeo4j;
import org.neo4j.ogm.config.ClasspathConfigurationSource;
import org.neo4j.ogm.config.ConfigurationSource;
import org.neo4j.ogm.config.FileConfigurationSource;
import org.neo4j.ogm.session.Session;
import org.neo4j.ogm.session.SessionFactory;
import org.springframework.context.annotation.*;
import org.springframework.data.neo4j.config.Neo4jConfiguration;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.transaction.Neo4jTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableNeo4jRepositories("yuzhaoLiu.project.repository")
@EnableTransactionManagement
@ComponentScan("yuzhaoLiu.project")
public class PersistenceContext extends Neo4jConfiguration {
@Bean
public SessionFactory getSessionFactory() {
return new SessionFactory(getConfiguration(),"yuzhaoLiu.project.entity");
}
@Bean
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public Session getSession() throws Exception {
return super.getSession();
}
//The purpose of this method is that I want to change the path of
//neo4j's configuration file called ogm.properties.
@Bean
public org.neo4j.ogm.config.Configuration getConfiguration() {
ConfigurationSource props = new ClasspathConfigurationSource("neo4j/ogm.properties");
org.neo4j.ogm.config.Configuration configuration = new org.neo4j.ogm.config.Configuration.Builder(props).build();
return configuration ;
}
}
然后我运行 Junit 测试,它返回一个如下所示的异常。
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:117)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:228)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:230)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:249)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:193)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jMappingContext' defined in yuzhaoLiu.project.testNeo4j.PersistenceContext: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.neo4j.mapping.Neo4jMappingContext]: Factory method 'neo4jMappingContext' threw exception; nested exception is java.lang.NoSuchMethodError: org.neo4j.ogm.session.SessionFactory.metaData()Lorg/neo4j/ogm/MetaData;
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:775)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:125)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:109)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:261)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)
... 24 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.neo4j.mapping.Neo4jMappingContext]: Factory method 'neo4jMappingContext' threw exception; nested exception is java.lang.NoSuchMethodError: org.neo4j.ogm.session.SessionFactory.metaData()Lorg/neo4j/ogm/MetaData;
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 41 more
Caused by: java.lang.NoSuchMethodError: org.neo4j.ogm.session.SessionFactory.metaData()Lorg/neo4j/ogm/MetaData;
at org.springframework.data.neo4j.config.Neo4jConfiguration.neo4jMappingContext(Neo4jConfiguration.java:66)
at yuzhaoLiu.project.testNeo4j.PersistenceContext$$EnhancerBySpringCGLIB$$7c8d8ebc.CGLIB$neo4jMappingContext$7(<generated>)
at yuzhaoLiu.project.testNeo4j.PersistenceContext$$EnhancerBySpringCGLIB$$7c8d8ebc$$FastClassBySpringCGLIB$$f976525a.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356)
at yuzhaoLiu.project.testNeo4j.PersistenceContext$$EnhancerBySpringCGLIB$$7c8d8ebc.neo4jMappingContext(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 42 more
下面是我的项目结构的图片。 my project's structure这个方法的目的是我想改变neo4j的配置文件ogm.properties的路径。我看过一个文档,链接是什么https://neo4j.com/docs/ogm-manual/current/reference/关于“使用属性文件”。然后出现一个我无法解决的错误。如果您能帮助我解决它,我将不胜感激。
最佳答案
您正在混合 OGM 相关依赖项的版本:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>4.1.0.RELEASE</version>
</dependency>
将引入 OGM 2.0.1。看compatibility matrix查看版本之间如何交互。
您还明确声明 OGM 版本为 3.0.0。这将导致使用 lib 的行为在某种程度上是不可预测的。 (这是可以预见的,但超出了这个答案)
因此,如果不需要保留这样的旧版本,您应该将 spring-data-neo4j 依赖项更新为最新版本,例如 5.0.3.RELEASE。这也将引入 OGM 3.0.3。
关于java.lang.NoSuchMethodError : org. neo4j.ogm.session.SessionFactory.metaData()Lorg/neo4j/ogm/MetaData;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48515851/
val jobConf = new JobConf(hbaseConf) jobConf.setOutputFormat(classOf[TableOutputFormat]) jobConf.s
我为我的项目创建了一个新模块来添加一些额外的功能。在该模块中,我在模块的 Gradle 文件 implementation 'org.jsoup:jsoup:1.10.2' 中添加了 Jsoup 依赖
我已经能够使用出色的任务 appStartWar 或 tomcatStartWar 成功地在tomcat上部署我的Web应用程序 war 文件,但是当我尝试使用 appStart 或到位部署同一Web
我正在使用具有 Maven 支持的 Intellij 启动 tomcat。一旦我添加以下 tomcat maven 依赖项: org.apache.tomc
请帮忙。我正在尝试使用 Jboss 8.1.0 缓存功能做一个简单的缓存机制。这就是我实现项目结构的方式: pomn 文件: 4.0.0 org.jboss
我正在使用 Espresso 进行仪器测试,但在堆栈跟踪中出现此错误: 错误是由缺少的类引起的,如下所示: Caused by: java.lang.ClassNotFoundException: D
早些时候,我的 Android 项目运行良好。但是在更新客户端提供的 .aar 库后,我收到了这个错误。 在我们的项目中,我们没有在任何地方使用 jacoco 依赖项 java.lang.NoClas
我正在尝试使用 wildfly-8 在本地计算机上运行的 Web 应用程序中显示图形报告,但遇到了下一个错误。 java.lang.NoClassDefFoundError: Lorg/jfree/c
我遇到了应用程序崩溃和提供此堆栈跟踪的问题 java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/commons/code
我在进行插桩测试时遇到了以下运行时错误。 Unknown source file : UNEXPECTED TOP-LEVEL EXCEPTION: Unknown source file : com
这个问题在这里已经有了答案: Android Studio : Error injecting while Appengine backend generation (1 个回答) 关闭 8 年前。
httpPost 在所有 8.1 及以下版本的 android 设备中运行,但在 android 9.0 中运行时出现如下错误, Failed resolution of: Lorg/apache/h
从昨天开始我就有麻烦了。在我的实习中,我遇到了以下构建错误,但我不明白为什么: $ cordova build android [...] FAILURE: Build failed with an
有人可以告诉我如何解决这个问题吗?我试图创建一个新的 Maven 项目,但由于某种原因失败了 描述资源路径位置类型目标 org.apache.maven.plugins:maven-resources
我正在从 Tomcat 6.0.24 升级到 7.0.23。我有一个 maven 2.2.1 项目,它使用 jspc maven 插件预编译 JSP。 当我为我的应用程序部署 WAR 文件并尝试访问
我收到以下错误: Process: com.project.publiko, PID: 27061 java.lang.NoSuchFieldError: No static field INSTAN
错误: E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1 Process: com.azail.cart.debug, PID: 2403
每当我尝试为我的项目构建 APK 时,都会收到以下错误: Error:Error converting bytecode to dex: Cause: com.android.dex.DexExcep
我是用java创建一个strut项目但是报错。我认为此错误是由于缺少 jar 文件造成的,我不知道要下载哪个版本。 这是我的 lib 文件夹中的 jar 文件: commons-digester-2.
我想使用最新的 JUnit 版本: org.junit.jupiter junit-jupiter-engine
我是一名优秀的程序员,十分优秀!