How to run a Restfull project on the Tomcat server?

Asked

Viewed 100 times

0

I created a simple project, and manage to run it in Springtools, to be able to run it also on the server Heroku and now I’m trying to run it on Tomcat server on my local computer.

i put Tomcat to run, and bundled the project with the command;

MVN clean install

took the project that is with . War and put in the webapp folder on the way;

C: Program Files Apache Software Foundation Tomcat 8.5 webapps

When I was testing in Postman did not run , gives error 404, I wonder what might have happened?

When I put the . War file in the project it generated a folder called midia as you can see in the figure below

inserir a descrição da imagem aqui

It generated a different folder from the original project as you can see below;

Project

all I need is to be able to run my project on my local server.

Structure of my project;

inserir a descrição da imagem aqui

1 answer

1

have to add this artifact

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>

and modified it

@SpringBootApplication
public class MidiaApplication {

    public static void main(String[] args) {
        SpringApplication.run(MidiaApplication.class, args);
    }
}

for that reason;

@SpringBootApplication
public class MidiaApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(MidiaApplication.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(MidiaApplication.class);
    }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.