刚开始接触SpringBoot,看了一些入门的资料,但是比较有意思的是从最简单的hello world到后面代码都不变了啊23333,要改注解的
不是在含main的类里增加其他包含RequestMapping的controller的类的定义,需要对含main函数的类进行注解,以指向controller类。
方法有两种,一种是用
@ComponentScan(value = {"controller所在包名"})
另一种是用
@SpringBootApplication
例如含RequestMapping的类:
要让这个生效,就需要对含main的类增加注解,ComponentScan方式:
另一种SpringBootApplication方式: