请帮帮我。当我运行我的应用时,不要显示任何错误。但是当我访问网址#define VARS(data, stride, a, b, c) \
MyStruct *a = &data.array[0], \
MyStruct *b = &data.array[1 * (stride)], \
MyStruct *c = &data.array[2 * (stride)];
时。我收到内部服务器错误(localhost:8080/api/wines or localhost:8080/api/wines/1
)。
我做错了什么?
这是我的Rest课程:
NullPointerException: null
}
我的WineServiceImplamatation类:
@RestController
@RequestMapping("/api")
public class VinhosRestController {
@Autowired
VinhosService vinhoService;
/* Retrieve all wines */
@RequestMapping(value = "/wines/", method = RequestMethod.GET)
public ResponseEntity<List<Vinho>> listAllWines() {
List<Vinho> vinhos = vinhoService.findAllWines();
if(vinhos.isEmpty()) {
return new ResponseEntity<List<Vinho>>(HttpStatus.NO_CONTENT);
}
return new ResponseEntity<List<Vinho>>(vinhos, HttpStatus.OK);
}
/* Retrieve single wine */
@RequestMapping(value = "/wines/{id}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Vinho> getWine(@PathVariable("id") Long id) {
Vinho vinho = vinhoService.findById(id);
if(vinho == null) {
return new ResponseEntity<Vinho>(vinho, HttpStatus.NOT_FOUND);
}
return new ResponseEntity<Vinho>(vinho, HttpStatus.OK);
}
我的界面服务类:
@Service("vinhoService")
@Transactional
public class VinhosServImp implements VinhosService {
private List<Vinho> vinhos;
public Vinho findById(Long id) {
for(Vinho vinho : vinhos) {
if(vinho.getCodigo() == id) {
return vinho;
}
}
return null;
}
@Override
public List<Vinho> findAllWines() {
return vinhos;
}
我的日志:
public interface VinhosService {
Vinho findById(Long id);
List<Vinho> findAllWines();
}