无法将Spring Boot容器部署到apt-get安装Tomcat

时间:2016-02-01 13:50:31

标签: spring spring-mvc tomcat spring-boot apt

我想将Spring Boot war文件部署到通过apt-get安装的Tomcat服务器。 war文件应该处理来自前端的一些REST调用。

该应用程序已在我的IDE中作为独立的jar文件运行良好,并且已在通过从Apache Tomcat主页解压缩二进制文件而安装的Tomcat服务器上运行。

我试图将战争部署到Tomcat 7和8,它们是通过apt-get安装的,但两次都没有用。 war文件似乎被Tomcat正确加载,因为日志文件中没有错误,war文件的文件夹是在/ webapps中创建的。但每当我尝试访问/调用应用程序的端点时,我都会收到404错误。

通过解压缩二进制文件安装的Tomcat服务器和通过apt-get安装的Tomcat服务器之间是否有任何区别可能导致Spring Boot war文件停止工作?

这是我的Spring Boot配置类的样子:

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableAutoConfiguration
@ComponentScan
@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);
}

}

这是应用程序的gradle文件:

buildscript {
repositories {
    mavenCentral()
    maven {
        name = "Spring snapshot"
        url = "http://repo.springsource.org/snapshot"
    }
    maven {
        name = 'Spring milestone'
        url = "http://repo.springsource.org/milestone"
    }
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.2.RELEASE")
}
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'war'
apply plugin: 'spring-boot'

repositories {
    mavenCentral()
}

war {
    baseName = 'project'
}

bootRepackage {
    mainClass = 'packagepath.Application'
}

configurations{
    providedRuntime
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
    //Spring
    compile 'org.springframework.boot:spring-boot-starter-web:1.2.2.RELEASE'
    compile 'org.springframework.boot:spring-boot-gradle-plugin:1.2.2.RELEASE'
    providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat:1.2.2.RELEASE'
}

springBoot {
}

0 个答案:

没有答案