Versuchen Sie, meinen Web-Service durch Rest-Client http://localhost:8080/gurukul/userList zu schlagen, aber es zeigt Fehler 'nicht gefunden'.Rest Web-Service-Pfad nicht gefunden
{
"timestamp": 1462078050576
"status": 404
"error": "Not Found"
"message": "No message available"
"path": "/gurukul/userList"
}
unten ist mein Controller, in der I-Pfad hinzufügen, indem RequestMapping aber immer noch nicht den Weg nach Feder-boot
package controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import bean.UserList;
import common.Status;
import constants.Constants;
import constants.Messages;
import dao.UserListDAO;
@EnableAutoConfiguration
@Controller
@RestController
@RequestMapping("gurukul")
public class GurukulController {
@RequestMapping(value = "/userList", method = RequestMethod.GET)
@ResponseBody
public Map<String, Object> getUsersList() {
ApplicationContext context = new ClassPathXmlApplicationContext("Spring-Module.xml");
UserListDAO userListDAO = (UserListDAO) context.getBean("userListDAO");
Map<String, Object> resultMap = new HashMap<>();
List<UserList> listResult = userListDAO.getUsers();
if (listResult != null) {
resultMap.put(Constants.RESULT, listResult);
resultMap.put(Constants.STATUS, Status.SUCCESS);
} else {
resultMap.put(Constants.RESULT, Messages.UNABLE_TO_GET_USERS_LIST);
resultMap.put(Constants.STATUS, Status.FAILURE);
}
return resultMap;
}
}
enter code here
Sind Sie ein eingebettetes Behälter mit oder auf einem eigenständigen Container bereitstellen? Wenn es ersteres ist, wie sieht Ihre Hauptklasse aus und in welchem Paket ist sie? Wenn es das letztere ist, hast du 'SpringBootServletInitializer' erweitert? Welchen Kontextpfad verwenden Sie in beiden Fällen? Ein [minimales, vollständiges, verifizierbares Beispiel] (http://stackoverflow.com/help/mcve) wäre hier sehr nützlich. –