How to add tomcat server on visual studio code?

Viewed 7686

My current spring boot project is running without error, but it cannot show on the Web page. I think because I need a Tomcat server. So I installed it from extension called Tomcat for Java

But after I installed it, I can't find its location path. So I cant add a tomcat server and cant run on the web page. In the window computer, it is can select easily.

I am using mac . Please guide me with it

enter image description here

1 Answers

First of all, you don't need another tomcat to run your spring boot application as spring boot has a tomcat embedded for you by default (Provided you have spring-boot-starter-web dependency in your pom.xml file).

Once you have coded everything, go to your project directory and do a

mvn clean install

This will package your application into a jar/war file (based on pom.xml). In your target folder you will have a jar/war file generated. You can simply open terminal in your target folder and run

java -jar your_JarName.jar

This will start your spring boot app. Now go to the browser and load http://localhost:8080/hello?name=abc you should be able to see the output.

If it doesn't work, check if you have changed the default port in your application.properties file. If your application.properties has server.port=8081 then you need to modify your URL accordingly http://localhost:8081/hello?name=abc

Related