0
votes

I have create a Spring Boot application successfully and when i execute the application via eclipse run as-> Spring Boot Application the application start successfully and i am able to access the home page via http://local host:8080/

But i start the tomcat independently and deploy the war file using tomcat app manager i am not able to access my application by http://local host:8080/ as this will open the tomcat home page not my applications. Can you please help me on this?

3

3 Answers

1
votes

The following steps should work:

  1. Navigate to TOMCAT_HOME/webapps directory.
  2. Rename the ROOT directory.
  3. Create an empty directory ROOT inside TOMCAT_HOME/webapps
  4. Copy the contents of your WAR file to TOMCAT_HOME/webapps/ROOT directory
  5. Restart tomcat and see if http://localhost:8080 works.

However, the right approach would be to create a specific context path for your web application and set is as docBase in your server.xml. Please refer How to set the context path of a web application in Tomcat 7.0 for more information.

0
votes

Please noticed two things:

1 update the deploy type as "war" in pom.xml

2 don't set server.port in application.properties

3 ensure tomcat jar is provided in pom.xml

Please follow this link: https://www.mkyong.com/spring-boot/spring-boot-deploy-war-file-to-tomcat/

0
votes

In the application.properties file mention below,

server.port = 8080
server.contextPath=/myapp

Deploy myapp.war into server and Hit url in browser:

http://localhost:8080/myapp

Note: if you are using jar run then use below,

java -jar myapp.jar or From Eclispe you can do run as --> Application