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