Setting up port on tomcat

2

I'm developing various services and these run on port 8080 by tomcat.

As the next services to be generated are not related to the services that have already been generated, the port was requested to 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, but service mapping is not being done.

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

    
asked by anonymous 11.10.2016 / 16:58

1 answer

2

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

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

    
18.01.2017 / 14:57