Springboot项目启动后访问不到Controller

1.搭建一个简单的Springboot项目,最开始将启动类main函数与controller放到一个类里,可以正常启动和访问,但是将两个分开再启动时访问就会报错:This application has no explicit mapping for /error, so you are seeing this as a fallback.

2、解决方案

  在main函数启动类上加注解:@SpringBootApplication(scanBasePackages = "com") 问题即可解决。

 

@SpringBootApplication(scanBasePackages = "com")
@EnableAutoConfiguration
public class Application {

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class, args);
    }

}

  

posted @ 2018-11-21 10:51  无敌小怪兽!  阅读(2258)  评论(0编辑  收藏  举报