Springboot项目启动后访问不到Controller

controller 方法中

@Controller改为
@RestController

原文地址:https://www.cnblogs.com/lixxx/p/11323571.html

时间: 2024-08-01 07:25:27

Springboot项目启动后访问不到Controller的相关文章

springboot启动后访问不到controller

springboot启动后访问有几个原因导致: 1.Application.java文件不在父目录,当启动springboot时@SpringBootApplication注解会去自动扫描当前目录和其子目录,如果controller层不在子目录则扫描不到.所以将其配置到子目录中. 2.在application.properties中配置   这里配置jsp的跳转页面 spring.mvc.view.prefix: /WEB-INF/jsp/spring.mvc.view.suffix: .jsp

SpringBoot项目启动成功,访问路径提示404

当SpringBoot项目启动成功后,访问Controller下的RequestMapping路径却发现无法访问,且提示Status=404 我的项目中controller下只有一个访问路径/hello,正常情况下当项目启动成功,会在控制台看到项目启动时扫描到该路径:@RequestMapping(value="/hello") ;但是我们看控制台此时并没有扫描到/hello路径 /hello路径无法成功访问 到这里就需要检查你的SpringBoot启动类是否与你的Controoler

springboot项目启动成功后执行一段代码的两种方式

springboot项目启动成功后执行一段代码的两种方式 实现ApplicationRunner接口 package com.lnjecit.lifecycle; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.core.annotation.Order; import org.sp

SpringBoot 项目打包后获取不到resource下资源的解决

SpringBoot 项目打包后获取不到resource下资源的解决 在项目中有几个文件需要下载,然后不想暴露真实路径,又没有CDN,便决定使用接口的方式来获取文件.最初的时候使用了传统的方法来获取文件路径,发现不行.查找资料后发现是SpringBoot框架导致的,得用另外的方法: //听说在linux系统中会失效. //不用听说了,就是会挂,血的教训 String path = ResourceUtils.getURL("classpath:").getPath(); //此方法返回

第一个springboot项目启动报错Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

报错内容具体如下 *************************** APPLICATION FAILED TO START *************************** Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a

alimama open source mdrill启动后访问蓝鲸任务时出错:Caused by:org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss

启动后,访问:http://IP:1107/mdrill.jsp  蓝鲸任务 即http:/IP:1107/topology.jsp 页面出现如下错误: HTTP ERROR 500 Problem accessing /topology.jsp. Reason: KeeperErrorCode = ConnectionLoss Caused by: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperError

Tomcat启动后访问首页报错 显示JSP 空指针异常

HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: java.lang.NullPointerException org.apache.jasper.serv

springboot项目启动之后初始化自定义配置类

前言 今天在写项目的时候,需要再springboot项目启动之后,加载我自定义的配置类的一些方法,百度了之后特此记录下. 正文 方法有两种: 1. 创建自定义类实现 CommandLineRunner接口,重写run()方法.springboot启动之后会默认去扫描所有实现了CommandLineRunner的类,并运行其run()方法. @Component @Order(2) //通过order值的大小来决定启动的顺序 public class AskForLeave implements

springboot项目启动报错 url' attribute is not specified and no embedded datasource could be configured

报错相关信息: 2019-07-22 17:12:48.971 ERROR 8312 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: Failed to configure a DataSource: 'url' attribute is not