0

Generally, we downloaded the TOMCAT to the computer and configure the context where it stores the project path then run the TOMCAT. So we can access our web project. Is there a possibility that we can start the TOMCAT by just using java code. like

Tomcat tomcat = new Tomcat(configuration);
tomcat.run();
Arslanbekov Denis
  • 1,674
  • 12
  • 26
Kai
  • 11
  • 6

1 Answers1

0

Can not understand what are you trying to achieve? But, Spring Boot comes with embedded tomcat and your application is deployed automatically on tomcat (with default configurations). If you want to change configurations for the tomcat you can specify those configurations in application.properties. Like, e-g if you want to change port of your server you can specify following property in application.properties.

server.port = 8085

There are other server related properties for which you can refer to https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html.

You can also implement WebServerFactoryCustomizer in order to configure tomcat with java. For this purpose you can refer to https://docs.spring.io/spring-boot/docs/current/reference/html/howto-embedded-web-servers.html

Muneeb Shahid
  • 223
  • 4
  • 13
  • Yes, it is what I really want to do. My project only contains one HTML page and some documents. And I want to develop a desktop APP to deploy the project automatically without installing and configuring TOMCAT. Could you please provide some examples or references? Thank you very much in advance. – Kai Nov 06 '18 at 03:20
  • You need to search for creating standalone or non-web application development in Spring Boot and in that case you won't be needing any kind of server (TOMCAT), refer to https://www.mkyong.com/spring-boot/spring-boot-non-web-application-example/. Why do you want to use HTML for desktop app? For GUI development of desktop app you can look for Java Swing / JavaFX, refer to https://dzone.com/articles/htmlcssjavascript-gui-java-0 – Muneeb Shahid Nov 06 '18 at 05:31