部署java web应用程序.war文件后未find404
我使用Spring框架在java中编写了一个Web应用程序。 测试并部署到远程Tomcat服务器。 部署后,我有消息OK - Started application at context path [/proxynator]
。 但是,如果我使用链接像http://109.206.178.66:8080/proxynator/
和http://109.206.178.66:8080/proxynator/proxynator/test
我有404 – Not Found
和Description: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
在应用程序中,我有起动器类
@SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
和控制器
@RestController @RequestMapping("/proxynator") public class MainController { @Autowired private ProxyRepo proxyRepo; @Autowired private CountryRepo countryRepo; @RequestMapping("/countries") @ResponseBody public List findCountries() { return countryRepo.findAll(); } @RequestMapping("/test") @ResponseBody public String testMethod() { return "HELLO"; } }
我不知道,为什么我有这个问题,因为我设置我的tomcat服务器的权利,我的控制器的路径是正确的,并在服务器上的应用程序正在运行。 任何想法如何解决?
UPD
我改变了我的控制器,如:
@RestController public class MainController { @Autowired private CountryRepo countryRepo; @RequestMapping("/countries") @ResponseBody public List findCountries() { return countryRepo.findAll(); } @RequestMapping("/") @ResponseBody public String testMethod() { return "HELLO"; } }
现在我的输入点是调用testMethod()
,但它不工作。
为了解决这个问题,我扩展了SpringBootServletInitializer
并覆盖了configure方法
@Override override fun configure(application: SpringApplicationBuilder?): SpringApplicationBuilder { return super.configure(application) }
我改变了正式文件中的项目结构。 现在它运作良好。
PS
我是Kotlin的改写项目