Java 我得到了';创建名为';requestMappingHandlerAdapter';在类路径资源中定义';用于我的spring boot应用程序
我很难用spring启动我的服务器。我查找了与我类似的错误,这似乎与我使用请求映射的方式有关。尽管尝试了各种方法来定义我的路线,但我仍然无法找出问题所在。有什么想法吗 这是我的错误消息:Java 我得到了';创建名为';requestMappingHandlerAdapter';在类路径资源中定义';用于我的spring boot应用程序,java,spring,spring-boot,hibernate,spring-mvc,Java,Spring,Spring Boot,Hibernate,Spring Mvc,我很难用spring启动我的服务器。我查找了与我类似的错误,这似乎与我使用请求映射的方式有关。尽管尝试了各种方法来定义我的路线,但我仍然无法找出问题所在。有什么想法吗 这是我的错误消息: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error cr
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Unsatisfied dependency expressed through method 'requestMappingHandlerAdapter' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConversionService' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'qualificationRepository' defined in com.salay.christophersalayportfolio.repositories.QualificationRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean 'jpaMappingContext' while setting bean property 'mappingContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.salay.christophersalayportfolio.models.ProgrammingLanguage.dissertation in com.salay.christophersalayportfolio.models.Dissertation.programmingLanguages
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Unsatisfied dependency expressed through method 'requestMappingHandlerAdapter' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConversionService' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'qualificationRepository' defined in com.salay.christophersalayportfolio.repositories.QualificationRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean 'jpaMappingContext' while setting bean property 'mappingContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.salay.christophersalayportfolio.models.ProgrammingLanguage.dissertation in com.salay.christophersalayportfolio.models.Dissertation.programmingLanguages
我的任务控制器
import com.salay.christophersalayportfolio.models.Task;
import com.salay.christophersalayportfolio.repositories.TaskRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Optional;
@RestController
@RequestMapping(path = "/api/v1/tasks")
public class TaskController {
@Autowired
private TaskRepository taskRepository;
@RequestMapping(value = "/add", method = RequestMethod.POST)
public @ResponseBody String add(@RequestBody Task task) {
taskRepository.save(task);
return "Successfully saved the task to the database.";
}
@RequestMapping(value = "/{id/", method = RequestMethod.GET)
public Task getById(@PathVariable int id){
Optional<Task> task = taskRepository.findById(id);
if(!task.isPresent()){
throw new NullPointerException();
}
else {
return task.get();
}
}
@RequestMapping(value = "/all/", method = RequestMethod.GET)
public List<Task> getAll() {
return taskRepository.findAll();
}
}
import javax.persistence.*;
导入java.util.Set;
@实体
公共类项目{
@身份证
@GeneratedValue(策略=GenerationType.AUTO)
私有int-id;
公共字符串名称;
公共字符串描述;
公共字符串客户端;
@OneToMany(mappedBy=“项目”)
公共集编程语言;
@OneToMany(mappedBy=“项目”)
公共设置工具;
@OneToMany(mappedBy=“项目”)
公共场景图像;
@OneToMany(mappedBy=“项目”)
公共任务;
}
我的pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.salay</groupId>
<artifactId>christopher-salay-portfolio</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>christopher-salay-portfolio</name>
<description>Back-end application for my portfolio</description>
<properties>
<java.version>1.8</java.version>
</properties>
<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-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>8.3.1.jre14-preview</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
4.0.0
org.springframework.boot
spring启动程序父级
2.3.0.1发布
com.salay
克里斯托弗·萨利投资组合
0.0.1-快照
克里斯托弗·萨利投资组合
我的投资组合的后端应用程序
1.8
org.springframework.boot
spring引导启动器数据jpa
org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
弹簧起动试验
测试
org.junit.vintage
朱尼特老式发动机
com.microsoft.sqlserver
mssql jdbc
8.3.1.jre14-预览
org.springframework.boot
springbootmaven插件
问题不在您的请求映射中,您的应用程序由于实体映射中的问题而无法启动,请按照错误中的说明仔细检查您的映射:mappedBy reference未知目标实体
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.salay.christophersalayportfolio.models.ProgrammingLanguage.dissertation in com.salay.christophersalayportfolio.models.Dissertation.programmingLanguages
您的类com.salay.christorsaaypolifolio.models.ProgrammingLanguage似乎没有名为demission的属性
否则,请共享您的模型以查看 问题不在您的请求映射中,您的应用程序由于实体映射中的问题而无法启动,请按照错误中的说明仔细检查您的映射:mappedBy reference a unknown target entity
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.salay.christophersalayportfolio.models.ProgrammingLanguage.dissertation in com.salay.christophersalayportfolio.models.Dissertation.programmingLanguages
您的类com.salay.christorsaaypolifolio.models.ProgrammingLanguage似乎没有名为demission的属性
否则,请共享您的模型以查看 我认为问题出在您的
编程语言
模型上。您还需要发布您的模型。我认为问题出在您的编程语言
模型上。您还需要发布您的模型~@arturo.bhn是正确的。我以前也遇到过类似的问题,可能是您的depose属性有一个@Id注释,而它不是主键。无论哪种方式,请发布您的双向关联实体。@arturo.bhn,我已经用实体更新了问题。该编程语言没有属性。我的许多模型的目的是创建多值属性。数据库本身有一个名为DessertationProgrammingLanguages的表。好的,您的问题在这里:@OneToMany(mappedBy=“desman”)查看本短文的第4节,这将帮助您了解映射是如何工作的。干杯~@阿图罗·布恩是对的。我以前也遇到过类似的问题,可能是您的depose属性有一个@Id注释,而它不是主键。无论哪种方式,请发布您的双向关联实体。@arturo.bhn,我已经用实体更新了问题。该编程语言没有属性。我的许多模型的目的是创建多值属性。数据库本身有一个名为DessertationProgrammingLanguages的表。好的,您的问题在这里:@OneToMany(mappedBy=“desman”)查看本短文的第4节,这将帮助您了解映射是如何工作的。干杯
package com.salay.christophersalayportfolio.models;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class Task {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
private int experienceId;
private int projectId;
public String description;
}
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class Task {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
private int experienceId;
private int projectId;
public String description;
}
import javax.persistence.*;
import java.util.Set;
@Entity
public class Project {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
public String name;
public String description;
public String client;
@OneToMany(mappedBy = "project")
public Set<ProgrammingLanguage> programmingLanguages;
@OneToMany(mappedBy = "project")
public Set<Tool> tools;
@OneToMany(mappedBy = "project")
public Set<String> images;
@OneToMany(mappedBy = "project")
public Set<Task> tasks;
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.salay</groupId>
<artifactId>christopher-salay-portfolio</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>christopher-salay-portfolio</name>
<description>Back-end application for my portfolio</description>
<properties>
<java.version>1.8</java.version>
</properties>
<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-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>8.3.1.jre14-preview</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.salay.christophersalayportfolio.models.ProgrammingLanguage.dissertation in com.salay.christophersalayportfolio.models.Dissertation.programmingLanguages