Spring Boot Uncover and Combat (v) Server-Tomcat code configuration

Source: Internet
Author: User
Tags tomcat server

The Tomcat server embedded in Spring Boot runs on port 8080 by default. If we need to modify the Tomcat port, we can configure the Tomcat information in Src/main/resources/application.properties.

    1. Server. Port=8089

Now, you can rerun the example above to see if the Tomcat port becomes 8089.

If you want to configure Tomcat directly from your code, you can define tomcatembeddedservletcontainerfactory directly.

Now, let's do a little makeover on the example above. First, comment out the configuration information above. Then register the tomcatembeddedservletcontainerfactory with a Bean.

  1. @Configuration
  2. Public class tomcatconfig {
  3. @Bean
  4. public embeddedservletcontainerfactory servletcontainer() {
  5. tomcatembeddedservletcontainerfactory tomcatfactory = new Tomcatembeddedservletcontainerfactory();
  6. Tomcatfactory. Setport(8089);
  7. return tomcatfactory;
  8. }
  9. }

Finish



If you feel that my article is helpful to you, please feel free to make a reward.

    • Copyright NOTICE: This article was published by Liang in Liang Blog
    • Reprint statement: Free reprint-Non-commercial-non-derivative-maintain attribution (Creative Sharing 3.0 license), non-commercial reprint please indicate the author and source, commercial reprint please contact the author himself.
    • Article title: Spring Boot Secrets and Combat (V) Server-Tomcat code configuration
    • Article Link: http://blog.720ui.com/2017/springboot_05_server_tomcat_embeddedfactory/

Spring Boot Uncover and Combat (v) Server-Tomcat code configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.