springboot入门测试时,启动服务器后,浏览器报错404无法访问资源

检查访问资源路径是否为服务入口所在同级或者下级包,因为注解@SpringBootApplication默认扫描同等路径及下级路径的包,如果想访问上级包的资源,需要通过@ComponentScan或@ComponentScans配置其他需要访问的资源路径在这里插入图片描述
我这里原本Demo00Application自动创建的这个类是在cn/springboot/demo00/这个目录下,所以服务器启动的时候无法访问IndexController里面的资源,百度没查出个所以然来,硬着头皮看了半天源码才发现这个问题
@ConfigurationPropertiesScan
public @interface SpringBootApplication {
@AliasFor(
annotation = EnableAutoConfiguration.class
)
Class<?>[] exclude() default {};

@AliasFor(
    annotation = EnableAutoConfiguration.class
)
String[] excludeName() default {};

@AliasFor(
    annotation = ComponentScan.class,
    attribute = "basePackages"
)
String[] scanBasePackages() default {};

@AliasFor(
    annotation = ComponentScan.class,
    attribute = "basePackageClasses"
)
Class<?>[] scanBasePackageClasses() default {};

@AliasFor(
    annotation = Configuration.class
)
boolean proxyBeanMethods() default true;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值