而與彈簧安置開始我得到了下面的錯誤作爲拋出:IllegalArgumentException:至少有一個JPA元模型必須存在
org.springframework.beans.factory.BeanCreationException:錯誤 創建名爲「jpaMappingContext」豆:調用初始化方法 失敗;嵌套異常是java.lang.IllegalArgumentException:在 必須存在至少一個JPA元模型! 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1595) 〜[彈簧豆-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-快照] 在有機.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:566) 〜[spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT] at org.springframework。在org.springframework.beans.factory中使用beans.factory.support.AbstractAutowireCapableBeanFactory.createBean .support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:304) 〜[spring-beans-5.0.0.BUILD-S NAPSHOT.jar:5.0.0.BUILD-SNAPSHOT] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 〜[spring-beans-5.0.0.BUILD-SNAPSHOT.jar :在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)5.0.0.BUILD-快照] 〜[彈簧豆-5.0.0.BUILD-SNAPSHOT.jar:5.0。 0.BUILD-SNAPSHOT] 在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) 〜[彈簧豆-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD -SNAPSHOT] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:725) 〜[spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BU ILD-SNAPSHOT] 在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) 〜[彈簧上下文5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) 〜[spring-context-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT] at org.springframework。 boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) 〜[spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT] at org.springframework.boot.SpringApplication .refresh(SpringApplication.java:736) [spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) [spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT] at org.springframework.boot。 SpringApplication.run(SpringApplication.java:313) [彈簧引導2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-快照] 在org.springframework.boot.SpringApplication.run(SpringApplication.java: 1161) [spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1150) [spring-boot- 2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT] at com.java.app.QuickPollApplication.main(QuickPollApplication.java:14) [classes /:na] 引起b y:java.lang.IllegalArgumentException:必須存在至少一個JPA元模型! at org.springframework.util.Assert.notEmpty(Assert.java:438)〜[spring-core-5.0.0.BUILD-SNAPSHOT.jar:5.0.0。BUILD-SNAPSHOT] at org.springframework.data.jpa.mapping.JpaMetamodelMappingContext。(JpaMetamodelMappingContext.java:52) 〜[spring-data-jpa-1.11.0.BUILD-SNAPSHOT.jar:na] at org。 springframework.data.jpa.repository.config.JpaMetamodelMappingContextFactoryBean.createInstance(JpaMetamodelMappingContextFactoryBean.java:71) 〜[spring-data-jpa-1.11.0.BUILD-SNAPSHOT.jar:na] at org.springframework.data.jpa .repository.config.JpaMetamodelMappingContextFactoryBean.createInstance(JpaMetamodelMappingContextFactoryBean.java:26) 〜[spring-data-jpa-1.11.0.BUILD-SNAPSHOT.jar:na] at org.springframework.beans.factory.config.AbstractFactoryBean。的afterPropertiesSet(AbstractFactoryBean.java:134) 〜[彈簧豆-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHO 5.0.0.BUILD-SNAPSHOT] :在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1654) 〜[彈簧豆-5.0.0.BUILD-SNAPSHOT.jar T] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1591) 〜[spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT] ... 16個共同幀省略
用下面的代碼
@SpringBootApplication
@RestController
public class QuickPollApplication {
public static void main(String[] args) {
SpringApplication.run(QuickPollApplication.class, args);
}
@RequestMapping(value = "/test", method = RequestMethod.GET)
public String testRest() {
return "rest tested";
}
和下面是我的pom.xml
UTF-8 UTF-8 1.8
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web-services</artifactId> </dependency> <dependency> <groupId>org.hsqldb</groupId> <artifactId>hsqldb</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> <repositories> <repository> <id>spring-snapshots</id> <name>Spring Snapshots</name> <url>https://repo.spring.io/snapshot</url> <snapshots> <enabled>true</enabled> </snapshots> </repository> <repository> <id>spring-milestones</id> <name>Spring Milestones</name> <url>https://repo.spring.io/milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>spring-snapshots</id> <name>Spring Snapshots</name> <url>https://repo.spring.io/snapshot</url> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> <pluginRepository> <id>spring-milestones</id> <name>Spring Milestones</name> <url>https://repo.spring.io/milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories>
Please help me. I do not know how to solve this error
因爲我是新來這個,我無法找到任何東西,你可以點我在正確的方向,請 –
@ user_xyz.LOL https://spring.io/guides/gs/accessing-data-jpa/ – sfat