简体   繁体   中英

How to deploy Spring-boot REST API in external tomcat

I have a Spring-boot gradle application which is not having any web pages.This application is having REST api's which are successfully getting called when i am running it as a Spring boot application.

Now after generation war from gradle, when i am trying to deploy it in apache-tomcat-8.0.35, it's getting deployed and directory structure is as follows:-

目录结构

but now i am not able to access my REST api with tomcat port 8080. I have already checked tomcat is up at http://localhost:8080 . On calling the REST Api I am getting the below error:

HTTP Status 403

Can anybody please help me with this.

Thanks

Add dependencies in build.gradle:

providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'

And add a class:

public class ServletInitializer extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM