解决关于spring boot 部署后试运行404问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37884383/article/details/84818736

如果是和主程序同意目录下,不会出现此问题,此问题只出现在和主程序class不在同一包下

@SpringBootApplication
@ComponentScan(basePackages = {"com.路径.*"})
public class DemoApplication {

   public static void main(String[] args) {
      SpringApplication.run(DemoApplication.class, args);
   }
}
在SpringBootApplication注解下添加ComponentScan注解,此注解用来扫描其他组件,spring boot 只会自动扫描它同一包下的路径,因此我们需要添加扫描注解,添加即可运行

猜你喜欢

转载自blog.csdn.net/qq_37884383/article/details/84818736