开发工具:idea
依赖方式:gradle
idea只选择web组件后,自动生成的springboot中的依赖是这样的:
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
改过之后成功运行:
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter-parent', version: '2.0.2.RELEASE', ext: 'pom'
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-tomcat')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
要加一个‘spring-boot-starter-parent’的依赖,还需将tomcat的 providedRuntime 改为 compile 就好了
需要弄清楚的是 compile 跟procidedRuntime、testCompile 的区别,后续更新