项目部署服务器报错404,SpringBoot application可以运行,但是打war包,并且部署到Tomcat服务器,运行报错404(springboot专属404页面)...

application

package com.allcam.fbs;

import javax.servlet.MultipartConfigElement;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;

import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;

import org.springframework.boot.builder.SpringApplicationBuilder;

import org.springframework.boot.web.servlet.MultipartConfigFactory;

import org.springframework.boot.web.support.SpringBootServletInitializer;

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.ComponentScan;

import org.springframework.context.annotation.Configuration;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

@RestController

@EnableAutoConfiguration

@SpringBootApplication(exclude={RedisAutoConfiguration.class,RedisRepositoriesAutoConfiguration.class})

@ComponentScan(basePackages = {"com.allcam.*"})

@Configuration

public class Application extends SpringBootServletInitializer

{

public static void main(String[] args)

{

SpringApplication.run(Application.class, args);

}

@RequestMapping("/hello")

public String index() {

return "Hello World";

}

/**

* 需要把web项目打成war包部署到外部tomcat运行时需要改变启动方式

*/

@Override

protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {

return builder.sources(Application.class);

}

/**

* 文件上传配置

*

* @return

*/

@Bean

public MultipartConfigElement multipartConfigElement()

{

MultipartConfigFactory factory = new MultipartConfigFactory();

// 单个数据大小

factory.setMaxFileSize("1024MB");

/// 总上传数据大小

factory.setMaxRequestSize("1024MB");

return factory.createMultipartConfig();

}

}

pom

org.springframework.boot

spring-boot-starter-tomcat

provided

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-starter-tomcat

provided

如果有servlet,还需要引入此jar包

javax.servlet

javax.servlet-api

provided

我工程的总的pom如下:

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

com.allcam.fbs

fbs

1.0.0

war

fbs

Spring Boot base web application

org.springframework.boot

spring-boot-starter-parent

1.5.9.RELEASE

UTF-8

com.allcam.fbs.Application

1.8

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-starter-tomcat

provided

io.springfox

springfox-swagger2

2.5.0

io.springfox

springfox-swagger-ui

2.5.0

com.alibaba

fastjson

1.2.13

org.apache.commons

commons-lang3

3.1

net.sf.ehcache

ehcache-core

2.6.8

org.apache.commons

commons-collections4

4.0

org.apache.httpcomponents

httpmime

commons-io

commons-io

2.5

com.belerweb

pinyin4j

2.5.0

commons-lang

commons-lang

2.6

commons-httpclient

commons-httpclient

3.1

dom4j

dom4j

1.6.1

org.quartz-scheduler

quartz

1.8.4

javax.servlet

javax.servlet-api

provided

repo2

http://repo2.maven.org/maven2

fbs

src/main/java

src/test/java

src/main/resources

src/test/resources

org.springframework.boot

spring-boot-maven-plugin

true

maven-war-plugin

2.6

true

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值