springboot测试
刚学习springboot的时候一直http://localhost:8080/hello一直报错,后面发现如果两个类不在一个包下,或者子包下,是无法扫描到的。
这个时候可以增加注解ComponentScan(value = “com.itsm”)即可
springboot测试的时候报404(Whitelabel Error Page)

@SpringBootApplication
@ComponentScan(value = “com.itsm”)
public class HelloApplication {
public static void main(String[] args) {
SpringApplication.run(HelloApplication.class, args);
}
}

@Controller
public class HelloController {
@ResponseBody
@RequestMapping("/hello")
public String hello(){
return “springboot test success”;
}
}

相关文章:

  • 2022-12-23
  • 2022-01-18
  • 2021-06-14
  • 2021-11-12
  • 2021-11-10
  • 2021-11-22
  • 2021-04-30
猜你喜欢
  • 2021-05-20
  • 2022-12-23
  • 2022-12-23
  • 2021-09-13
  • 2022-02-09
  • 2021-10-15
  • 2021-05-24
相关资源
相似解决方案