How to run a RestFull project on the TomCat server?

0

I created a simple project, and managed to run it in SpringTools, can also run it on the Heroku server and now I'm trying to run it on the TomCat server on my local computer.

I put tomcat to run, and I packed the project with the command;

  

MVN clean install

I took the project that is with .war and put it in the webapp folder in the path;

  

C: \ Program Files \ Apache Software Foundation \ Tomcat 8.5 \ webapps

When I was testing in postman it did not run, it gives 404 error, what could have happened?

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

Itgeneratedafolderdifferentfromthatoftheoriginalprojectasyoucanseebelow;

Project

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

My project structure;

    
asked by anonymous 13.04.2018 / 17:02

1 answer

1

You have to add this artifact

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

and I modified it

@SpringBootApplication
public class MidiaApplication {

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

for this;

@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);
    }
}
    
13.04.2018 / 20:38