michael
michael

Reputation: 3945

Spring Maven rest web service - What is the URL when deploying on real web server?

I followed this tutorial https://spring.io/guides/gs/rest-service/ by creating maven project in intellij, addind pom.xml etc. Then I run on localhost exactly as written in the tutorial and all works:

http://localhost:8080/greeting When greeting came from the annotation of method in the controller @RequestMapping("/greeting").

Then I made JAR artifact & deployed it to Tomact on 'real server' (Elastic beanstalk environment running EC2 instance on AWS).

I got from AWS the base URL of my webserver running Tomact. What is now the suffix to my service? This is NOT working:

http://someEnvironmentName.elasticbeanstalk.com/greeting

EDIT: How I made the artifact JAR

In intellij I can compile & run maven project and then test it in localhost. So what I did:

  1. Right click on the project name->Open Module Settings->Artifacts->Add->Jar

  2. Build->Build Artifacts->Selecting the Jar from above

Maybe I need to build WAR? And how to deal with the POM.xml? Now my pom is exactly as in the linked tutorial.

Thanks,

Upvotes: 1

Views: 995

Answers (2)

michael
michael

Reputation: 3945

Solution (Thanks to @JBNizet suggestion):

Follow this link http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file

  1. Modify the Application.java file
  2. Modify the pom.xml (By adding one more dependency)

Then if you are using Intellij IDE under Build->Build Artifacts will be automatically option for WAR file.

Just deploy to AWS elasticbeanstalk instance running EC2 in the usual way. The URL is:

http://someEnvironmentName.elasticbeanstalk.com/greeting

Upvotes: 0

Jose Antonio
Jose Antonio

Reputation: 598

If you use spring-boot, you don´t need a tomcat because spring include an embedded tomcat. Only you run the application with Maven. So, the advantage of spring-boot is not dependent on an application server and using other containers such as Docker.

Do you put the port in the call to your webserver?

On the other hand, check your server logs to see if there are any problem.

Upvotes: 1

Related Questions