报错是说找不到容器工厂类,一个原因是pom里没有引入embedtomcat,
第二个是用错了注解SpringBootApplication

//pom.xml   要有starter,表示使用内置tomcat容器

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.1.RELEASE</version>
    </parent>
<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
//错误注解在main启动类上面
import org.springframework.boot.SpringBootConfiguration;

@SpringBootConfiguration
//正确注解,放在main启动类上
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐