problem
Springboot 2.0 project, start error, exception: nested exception is java.lang.IllegalArgumentException : At least one JPA metamodel must be present!。
Details are as follows:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: At least one JPA metamodel must be present!
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1710) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:741) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at com.example.demo.JtademoApplication.main(JtademoApplication.java:22) [classes/:na]
Caused by: java.lang.IllegalArgumentException: At least one JPA metamodel must be present!
at org.springframework.util.Assert.notEmpty(Assert.java:450) ~[spring-core-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.data.jpa.mapping.JpaMetamodelMappingContext.<init>(JpaMetamodelMappingContext.java:54) ~[spring-data-jpa-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.data.jpa.repository.config.JpaMetamodelMappingContextFactoryBean.createInstance(JpaMetamodelMappingContextFactoryBean.java:88) ~[spring-data-jpa-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.data.jpa.repository.config.JpaMetamodelMappingContextFactoryBean.createInstance(JpaMetamodelMappingContextFactoryBean.java:43) ~[spring-data-jpa-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.beans.factory.config.AbstractFactoryBean.afterPropertiesSet(AbstractFactoryBean.java:141) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1769) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
... 16 common frames omitted
analysis
Spring boot supports JPA through spring boot starter data JPA. The default JPA implementer of spring boot is hibernate.
Due to pom.xml Spring boot starter data JPA is defined in the file.
<dependency>
<groupId> org.springframework.boot< ;/groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
At this time, the project will automatically open the following two auto configuration classes:
jparepositoriesautoconfiguration
hibernatejpaautoconfiguration
As long as there is such a definition, the JPA metamodelmappingcontext class will check during the startup process. At least one JPA metamodel must be defined. Otherwise, an at least one JPA metamodel must be present! Error will be reported.
The relevant source code of jpametametamodelmappingcontext is as follows:
/**
* Creates a new JPA {@link Metamodel} based {@link MappingContext}.
*
* @param models must not be {@literal null} or empty.
*/
public JpaMetamodelMappingContext(Set<Metamodel> models) {
Assert.notNull(models, "JPA metamodel must not be null!");
Assert.notEmpty(models, "At least one JPA metamodel must be present!");
this.models = models;
this.persistenceProvider = PersistenceProvider.fromMetamodel(models.iterator().next());
}
solve
Method 1: if JPA is not used in the system, remove the spring boot starter data JPA dependency.
Method 2: add @ enableautoconfiguration (exclude = {jparepositor) to the application iesAutoConfiguration.class }) notes.
Method 2 is mainly used for custom JPA configuration implementation.
The end of the article.
Read More:
- java.lang.IllegalArgumentException: error at ::0 can‘t find referenced pointcut anyMethod
- Failed to execute tools\ android.bat : minutes! The same thing on the Internet, can’t it be solved? Look at this one!
- java.lang.IllegalArgumentException: Address 127.0.0.1:5672:5672 seems to contain an unquoted IPv6
- Springboot startup error: java.lang.IllegalArgumentException : Property ‘sqlSessionFactory’ or ‘sqlSessionTempla
- Edit the file to be edited by gedit. After saving, a warning of Set document metadata failed: Setting attribute metadata::gedit-position no appears
- Edit the file to be edited by GEDIT. After saving, the warning set document metadata failed: setting attribute metadata:: GEDIT position no appears
- Solve the slanting problem of vscode one dark Pro topic annotation
- Error java.lang.IllegalArgumentException: Validation failed for query for method public abstract
- One of the ways to solve the problem of internal server error in flash learning
- Random number random reports an error. Illegalargumentexception: bound must be positive
- ValueError: need at least one array to concatenate
- Solve the problem that CEPH dashboard cannot be accessed
- Error c2951: template declaration can only be used at the global, namespace, or class scope. Error c2598: link specification must be at the global scope
- Solve the problem that data cannot be input in idea console
- “Hive metadata problem” hive.metastore.HiveMetaException : Failed to get schema version.
- Solve the problem that the newly installed CodeBlocks cannot be compiled and run
- Solve the problem that the connection between ADB and nocturnal God cannot be solved
- Solve the problem that the header file of “graphics. H” cannot be loaded in vs2015
- Solve the problem that Windows 7 cannot be updated automatically_ Prompt error code 80246008
- Solve the problem that the value in the disabled tag cannot be passed to the server