网站建设 荆州,企点营销软件,网站黑链怎么做的,做网站菜单背景图片根据spring可知道#xff0c;注解之所以可以使用#xff0c;是因为通过包扫描器#xff0c;扫描包#xff0c;然后才能通过注解开发。
那么springboot需要扫描哪里呢#xff1f;
springboot的默认包扫描器#xff0c;扫描的是自己所在的包和子包#xff0c;例子如下 我…根据spring可知道注解之所以可以使用是因为通过包扫描器扫描包然后才能通过注解开发。
那么springboot需要扫描哪里呢
springboot的默认包扫描器扫描的是自己所在的包和子包例子如下 我们此时在java中新建一个包与org同一等级那么里面的注解将失效 那么我们访问 “/changshi”的时候不出意外的出错了
那么我们怎么可以扩大包的扫描范围呢
通过
SpringBootApplication
里面的
ComponentScan(excludeFilters {Filter(type FilterType.CUSTOM,classes {TypeExcludeFilter.class}
)
可以规定包的扫描
语法如下
SpringBootApplication(scanBasePackages org.example)
通过这个配置来扩大包的扫描范围