得到 filename.java:6:错误:包org.springframework.boot.context.web不存在 import org.springframework.boot.context.web.SpringBootServletInitializer;
源代码: -
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
build.gradle: -
buildscript {
ext {
springBootVersion = '2.0.0.BUILD-SNAPSHOT'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
war {
baseName = 'temp'
version = '0.0.2'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
compile("org.springframework.boot:spring-boot-starter-jdbc")
compile("com.h2database:h2")
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile("junit:junit")
testCompile('org.springframework.security:spring-security-test')
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
}
任何指针都会非常有用。 是否缺少启动器依赖...
答案 0 :(得分:1)
您正在使用SpringBootServletInitializer
包中org.springframework.boot.web.servlet.support
的Spring Boot 2.0。