Configuring port in Tomcat

Asked

Viewed 161 times

2

I am developing various services and these are run at port 8080 by Tomcat.

Since the next services to be generated are unrelated to the services that have already been generated, it was requested that the port be modified.

I found the class TomcatEmbeddedServletContainerFactory that modifies the Tomcat port by java.

I made this code to modify the port:

public class TestContext {

    @Bean
    public EmbeddedServletContainerFactory servletContainer() {

        TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
        factory.setPort(2020);

        factory.addInitializers();

        return factory;
    }

}

The service runs normally and the port is being modified, only the mapping of the services is not being done.

I wanted an example of how to use this class to do the mapping. At least which method I have to use to do the mapping.

1 answer

2


The solution I found was to create a file application.properties inside the directory src/main/resources with the code server.port = 2020.

The mapping of the services is done correctly and the port is modified.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.