我正在处理位置杂项应用程序,添加jchart api后,我的程序无法运行。我得到的最大错误是
require
我正在使用spring-tool-suite 4和msysql工作台作为数据库。我已经尽可能多地进行了自动接线,不确定在哪里存在编译错误。
疑似LocationController页面
Error creating bean with name 'locationController':
Unsatisfied dependency expressed through field 'service';" and "location is not mapped [select type, count(type) from location group by type]
详细错误
package com.bthompson.location.controllers;
import java.util.List;
import javax.servlet.ServletContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.bthompson.location.entities.Location;
import com.bthompson.location.repository.LocationRepository;
import com.bthompson.location.service.LocationService;
import com.bthompson.location.util.EmailUtil;
import com.bthompson.location.util.ReportUtil;
import org.springframework.web.bind.annotation.ModelAttribute;
@Controller
public class LocationController {
@Autowired
LocationService service;
@Autowired
LocationRepository repository;
@Autowired
ServletContext sc;
@Autowired
EmailUtil emailUtil;
@Autowired
ReportUtil reportUtil;
@RequestMapping("/showCreate")
public String showCreate() {
return "createLocation";
}
@RequestMapping("/saveLoc")
public String saveLocation(@ModelAttribute("location") Location location, ModelMap modelMap) {
Location locationSaved = service.saveLocation(location);
String msg = "Location saved with id: "+ locationSaved.getId();
modelMap.addAttribute("msg", msg);
emailUtil.sendEmail("javadevbernard@gmail.com", "Location Saved", "This response means that the location save/update was successful");
return "createLocation";
}
@RequestMapping("/displayLocations")
public String displayLocations(ModelMap modelMap) {
List<Location> locations = service.getAllLocations();
modelMap.addAttribute("locations", locations);
return "displayLocations";
}
@RequestMapping("deleteLocation")
public String deleteLocaation(@RequestParam("id") int id, ModelMap modelMap) {
Location location = service.getLocationById(id);
service.deleteLocation(location);
List<Location> locations = service.getAllLocations();
modelMap.addAttribute("locations", locations);
return "displayLocations";
}
@RequestMapping("/showUpdate")
public String showUpdate(@RequestParam("id") int id, ModelMap modelMap) {
Location location = service.getLocationById(id);
modelMap.addAttribute("location", location);
return "updateLocation";
}
@RequestMapping("/updateLoc")
public String updateLocation(@ModelAttribute("location") Location location, ModelMap modelMap) {
service.updateLocation(location);
List<Location> locations = service.getAllLocations();
modelMap.addAttribute("locations", locations);
return "displayLocations";
}
@RequestMapping("/generateReport")
public String generateReport() {
String path = sc.getRealPath("/");
List<Object[]> data = repository.findTypeAndTypeCount();
reportUtil.generatePieChart(path, data);
return "report";
}
}
我希望信息可以转换为通过应用程序显示的图像。但是我遇到了编译错误。
答案 0 :(得分:0)
我查看了我的实体.Location文件,但尚未看到需要添加的内容,请查看我的代码。
package com.bthompson.location.entities;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class Location {
@Id
private int id;
private String name;
private String code;
private String type;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public String toString() {
return "Location [id=" + id + ", name=" + name + ", code=" + code + ", type=" + type + "]";
}
}