#Embedded Tomcat Spring Boot

1 messages ยท Page 1 of 1 (latest)

north bluffBOT
#

<@&1004656351647117403> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
Hi, I can't seem to find the answer on the web so I decided to ask it here. I want to run two Tomcat servers within my Spring Boot application. Obviously the first Tomcat server is automatically setup by Spring itself and runs on port 8080 which is fine, b

erver is embedded in Spring Boot by default, but I also want to add a separate Tomcat server to handle a specific set of requests. Is it possible to run multiple Tomcat servers in a single Spring Boot application? If so, how can I achieve this?

Yes, it is possible to run multiple Tomcat servers within a single Spring Boot application. To achieve this, you can create a separate configuration class for the additional Tomcat server. You can define this additional server using the TomcatServletWebServerFactory bean and configure the port and any other settings as needed.

Here's an example of how you can create an additional Tomcat server in your Spring Boot application:

@Configuration
public class AdditionalTomcatServerConfiguration {

    @Bean
    public ServletWebServerFactory additionalTomcatServerFactory() {
        TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
        factory.setPort(8081); // Set the port for the additional server
        // Add any other configurations as needed
        return factory;
    }
}

With this configuration in place, you can now run two separate Tomcat servers within your Spring Boot application. Just make sure to handle routing and request mapping accordingly to ensure that each server handles the appropriate set of requests.

junior terrace
#

In your application.properties you can configure your server port.

junior terrace
#

What's the second server for?