在spring boot啓動類上添加@ComponentScan註解
Springboot就會自動掃描啓動類同級包及其同級包的子包所有的註解
(注意:會替換spring boot默認的掃描包路徑,所以需要將默認的保路經添加到註解後邊以逗號分隔)
@SpringBootApplication
@ComponentScan(value="com.job,com.doc")
public class WebStart
{
public static void main(String[] args)
{
new SpringApplicationBuilder(WebStart.class).web(true).run(args);
}
}