我的移民课程如下:
@Configuration
@EnableAutoConfiguration
@ComponentScan(basePackages = "com.projectx")
public class Application extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(applicationClass, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
}
同样build.gradle
文件看起来像这样
apply plugin: 'java'
sourceCompatibility=1.8
targetCompatibility=1.8
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'war'
mainClassName = 'com.projectx.data.config.Application'
buildscript {
repositories {
maven { url "http://repo.spring.io/libs-release" }
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.1.RELEASE")
}
}
war {
baseName = 'gs-accessing-data-jpa'
version = '0.1.0'
}
repositories {
mavenLocal()
mavenCentral()
maven { url "http://repo.spring.io/libs-release" }
maven { url "https://repository.jboss.org/nexus/content/repositories/releases" }
}
configurations {
providedRuntime
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
}
因此,无论我将此项目部署到tomcat,它都会显示以下错误。因为我已经交配了将jar转换为战争的所有要求,所以不确定这个项目是什么问题。
它给出了404 NOT FOUND。(我使用带有Gradle插件的STS 3.6.0)