我正在学习SpringBoot。使用Spring JavaPersistenceAPI(JPA)和apache derby作为数据库。我在将URL映射到方法时遇到麻烦。
我有主题:
@Entity
public class Topic {
@Id
private String id;
private String name;
private String description;
public Topic() {
}
public Topic(String id, String name, String description) {
this.id = id;
this.name = name;
this.description = description;
} ... getters & setters...
Run Code Online (Sandbox Code Playgroud)
我有一个主题控制器。它工作正常:
@RestController
public class TopicController {
@Autowired
private TopicService topicServ;
@RequestMapping("/topics")
public List<Topic> getAllTopics() {
return topicServ.getAllTopics();
}
@RequestMapping("/topics/{topicId}")
public Topic getTopic(@PathVariable String topicId) {
return topicServ.getTopic(topicId);
}... more methods (they work fine) …Run Code Online (Sandbox Code Playgroud)