idan ovadia
idan ovadia

Reputation: 239

Using azure to run java app but access not working

I just started to work with the azure platform and I have a Question.

I upload my app to azure and run it but when I try to access it, it does not work but returns a 404 not found.

Maybe I did something wrong?

This is the repo that I connected:

https://github.com/idanovadia/ServerAlgoSearchImplementation_v2

for example when I run it on local host : http://localhost:8080/getMaze/prim

now I tried : https://searchnow.azurewebsites.net/getMaze/prim

here is the screen from azure

enter image description here

Upvotes: 0

Views: 554

Answers (1)

Jack Jia
Jack Jia

Reputation: 5549

I see that you try to package your java app to a jar file, and run the jar with a web.config in web app. This is the old way to run spring boot application.

In fact, there is a common and better way. It is just to package your spring boot application to a war package. And then you can deploy it to Azure web app with tomcat container.

1. You need to choose to package as war when you initialize the spring boot project:

enter image description here

2. Set the packaged file name to ROOT.war

Open the pom.xml, add the following line:

enter image description here

Then you will get a ROOT.war file if you run mvn clean package

3. Create a web app with Tomcat

enter image description here

4. Deploy ROOT.war under \site\wwwroot\webapps folder in web app

enter image description here

5. Restart your web app.

enter image description here

Upvotes: 1

Related Questions