- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 spring 代码出现以下错误,这是由实体类之一引起的。由于 Spring/JPA 没有提供任何关于错误来源的提示,我将不得不删除每个实体,直到找到罪魁祸首。通常会给出线索,但这里的情况并非如此。
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125) ~[spring-test-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108) ~[spring-test-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118) ~[spring-test-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83) ~[spring-test-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:44) ~[spring-boot-test-autoconfigure-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246) ~[spring-test-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227) [spring-test-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289) [spring-test-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291) [spring-test-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246) [spring-test-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) [spring-test-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) [spring-test-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) [spring-test-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365) [surefire-junit4-2.22.1.jar:2.22.1]
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273) [surefire-junit4-2.22.1.jar:2.22.1]
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238) [surefire-junit4-2.22.1.jar:2.22.1]
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159) [surefire-junit4-2.22.1.jar:2.22.1]
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384) [surefire-booter-2.22.1.jar:2.22.1]
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345) [surefire-booter-2.22.1.jar:2.22.1]
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126) [surefire-booter-2.22.1.jar:2.22.1]
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418) [surefire-booter-2.22.1.jar:2.22.1]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1745) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1083) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:853) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) ~[spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) ~[spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:127) ~[spring-boot-test-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) ~[spring-test-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117) ~[spring-test-5.1.4.RELEASE.jar:5.1.4.RELEASE]
... 28 common frames omitted
Caused by: java.lang.NullPointerException: null
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processFkSecondPassesInOrder(InFlightMetadataCollectorImpl.java:1749) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1658) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:287) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:904) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:935) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57) ~[spring-orm-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:390) ~[spring-orm-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377) ~[spring-orm-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1741) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
... 43 common frames omitted
最佳答案
运行多次“实体删除”-“编译”周期后,我发现了问题:标有 @ManyToOne 的 LocalDate 字段
通常会捕获此类错误并返回有用的错误消息,例如:
Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.entityClass.refereceDate references an unknown entity: java.time.LocalDate
这同样适用于其他对象,例如字符串:
Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.opsfactor.planning.model.domain.masterdata.production.RecursoProdutivoTeste.string references an unknown entity: java.lang.String
在我的例子中,该字段位于复合键内,因此结论是,当 @ManyToOne 注释分配给内部的 Integer、Long、Float、LocalDate 或 String 字段时,Hibernate 不会指定错误的实体/字段一个embeddedId类。
实体描述如下:
@Entity
public class TestClass{
@EmbeddedId
@NonNull // torna campo obrigatório e parâmetro do construtor gerado pelo @Data (lombok)
private TestCompositeKey testCompositeKey;
public static class TestCompositeKey implements Serializable {
@ManyToOne
private AnotherEntity anotherEntity;
@ManyToOne // (this line should be removed)
private LocalDate referenceDate;
}
}
关于java - Spring初始化中没有详细信息创建名为 'entityManagerFactory' + NullPointerException的bean时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59937095/
这个问题在这里已经有了答案: Is Git’s "master" branch name more than just a name? (3 个回答) What will break if I don
我使用了Plone实例文件夹的“bin /”目录中的“paster”命令来创建一个名为“MyApp”的plone应用程序(来自模板),该命令是: (from instance's root folde
我正在尝试覆盖 FOSUserBundle 的用户映射的两个属性。 use FOS\UserBundle\Model\User as BaseUser; ... use Symfony\Bridge\
工作通过 these posts让我认为我了解自我类型,至少在某种程度上。 所以我创建了一个按预期失败的例子: scala> trait A { val v = "a" } defined trait
我在 IntelliJ 中有一个 JavaFX Maven 项目,它使用 Hibernate。当应用程序启动时,我收到以下错误消息: No persistence provider for entit
我正在尝试构建一个数据透视表,并使用开源代码并摸索着这个函数。record[] 如何传递给这个函数?似乎没有经过或任何声明。怎么能直接来呢? 完整代码可以在这里找到https://github.com
我的应用程序有 abc.com 链接,这是一个主页和 abc.com/user123(有一个动态部分),这是一个用户登录的特定配置文件页面。 早些时候,我通过这样做实现了这一点: this.route
当我在使用 mac book pro 的 Android Studio 上设置 Flutter Sdk 路径时,我遇到错误 Flutter SDK 路径未给出(并且打开一个弹出窗口并显示消息“名为‘F
我刚刚设置了 Postgres 供我网络上的不同用户使用。每个用户都有自己的用户名/密码/数据库,但是当我连接到 Pg 时,我还可以看到一个“postgres”数据库(甚至可以创建表等)。我试图从公众
我正在尝试从 MySQL 数据库中获取一些数据。所以我要做的是: select * from my_table where 'to' ='0000-00-00 00:00:00'; 这给了我空集,但我
我有一个名为“索引”的表。我意识到这是 MySQL 中的关键字,想知道如何在查询中引用该表? 我的错误: #1064 - You have an error in your SQL syntax; c
我在机器 myuniversity.edu 上设置了一个远程 mysql 数据库服务器,服务器名为“localhost”。我在上面有一个名为“MyDatabase”的数据库。 I want to co
我正在尝试使用 Android NDK 构建应用程序。我已按照所有步骤操作,一切正常,正在制作 .so 文件。但是在 Eclipse 中,当我尝试清理项目时出现以下错误: The file does
我正在重写 UIImage 类方法 init(named:)。我的目标是能够检索图像的文件名。 代码看起来像这样: class UIImageWithFileName: UIImage { l
@ThreadSafe public class A { } 这个注解实际上使类线程安全还是只是为了提高可读性? 最佳答案 参见 @ThreadSafe Annotation : Place this
当我将第二个表(dtResult)添加到数据集时出现错误 名为“Table”的数据表已属于此数据集。 DataTable dtSession = new DataTable(); DataTable
这个问题可能看起来重复,但略有不同。在 SO 的所有其他问题中,我注意到他们注册了多条路线。但就我而言,我只有一条路线。 我正在创建 asp.net webapi(框架 4.5)并且在 Registe
我最近将 Microsoft.AspNet.WebApi.WebHost 添加到 MVC WebAPI 项目中,这将允许我使用 [Route("api/some-action")] 归因于我的行动。我
我有一个名为“异常”的命名空间的问题 让我们考虑以下示例标题: #include namespace exception { struct MyException : public std::e
我昨天安装了 Nuget 1.2,今天,当我尝试安装 Entity Framework 包时,我在包管理器控制台中遇到了以下问题: PM> install-package entityframewor
我是一名优秀的程序员,十分优秀!