{"id":133748,"date":"2025-05-27T21:09:09","date_gmt":"2025-05-27T18:09:09","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=133748"},"modified":"2025-05-27T21:09:11","modified_gmt":"2025-05-27T18:09:11","slug":"enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html","title":{"rendered":"Enable or Disable Embedded Tomcat in Spring Boot Using Profiles"},"content":{"rendered":"<p>In many Spring Boot applications, especially those that support multiple deployment modes, it is common to encounter different runtime environments. For instance, one mode might expose a RESTful API using an embedded Tomcat server, while another might rely purely on messaging (e.g., using JMS or Kafka) without needing any HTTP layer.<\/p>\n<p>In this article, we will explore how to conditionally enable or disable the embedded Tomcat server in Spring Boot using Spring Profiles.<\/p>\n<h2 class=\"wp-block-heading\">1. How Embedded Tomcat Works in Spring Boot<\/h2>\n<p>Spring Boot simplifies web application development by including <strong>embedded servlet containers<\/strong>, with <a href=\"https:\/\/tomcat.apache.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Tomcat<\/a> as the default. This means we don\u2019t need to deploy your application to an external application server. Instead, the application becomes a self-contained JAR that starts its own web server upon running.<\/p>\n<h3 class=\"wp-block-heading\">1.1 Why Embedded Tomcat?<\/h3>\n<ul class=\"wp-block-list\">\n<li><strong>Convenience<\/strong>: No need to install or manage Tomcat separately.<\/li>\n<li><strong>Portability<\/strong>: Run your application anywhere Java is available.<\/li>\n<li><strong>Control<\/strong>: You can easily configure or exclude web server behavior using Spring Boot&#8217;s auto-configuration features.<\/li>\n<\/ul>\n<p>By default, including <code>spring-boot-starter-web<\/code> pulls in the necessary dependencies to auto-configure Tomcat and start it on a specified port (default is 8080). However, this can be problematic in applications where not all profiles require a web layer. For example, background processing applications using JMS or scheduled jobs.<\/p>\n<p>That is where conditional configuration and profile-specific loading come in, allowing us to enable or disable embedded Tomcat as needed.<\/p>\n<h2 class=\"wp-block-heading\">2. Problem Statement<\/h2>\n<p>Imagine we are building a Spring Boot application that serves different functions depending on the active profile:<\/p>\n<ul class=\"wp-block-list\">\n<li>Under the <strong>&#8220;http&#8221;<\/strong> profile, it starts a REST server using Spring MVC and an embedded Tomcat.<\/li>\n<li>Under the <strong>&#8220;jms&#8221;<\/strong> profile, it listens to JMS queues, and a web server is not needed.<\/li>\n<\/ul>\n<p>Normally, including the <code>spring-boot-starter-web<\/code> dependency will cause Spring Boot to auto-configure an embedded web server (like Tomcat) and start it regardless of the active profile. This is undesirable when running in a non-web context.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>To prevent Spring Boot from loading the embedded web server by default, we need to set <code>spring.main.web-application-type=none<\/code> for non-web profiles, ensuring Tomcat is only initialized when explicitly enabled through a profile-specific configuration.<\/p>\n<h2 class=\"wp-block-heading\">3. Profile-Specific Configurations<\/h2>\n<p><strong>HTTP Profile &#8211; Enable Embedded Tomcat and REST Controller<\/strong><\/p>\n<p>Below, we define a configuration that only activates when the <code>http<\/code> profile is selected.<\/p>\n<pre class=\"brush:java\">\n@Profile(\"http\")\n@Configuration\n@RestController\npublic class HttpServerConfig {\n\n    @GetMapping(\"\/hello\")\n    public String sayHello() {\n        return \"Hello from HTTP profile!\";\n    }\n}\n<\/pre>\n<p><strong>JMS Profile &#8211; No Web Server<\/strong><\/p>\n<p>In the <code>jms<\/code> profile, we define a listener for JMS messages. No REST controllers are needed here.<\/p>\n<pre class=\"brush:java\">\n@Profile(\"jms\")\n@Configuration\n@EnableJms\npublic class JmsConfig {\n\n    @JmsListener(destination = \"input.queue\")\n    public void listen(Message message) {\n        try {\n            if (message instanceof TextMessage textMessage) {\n                System.out.println(\"Received JMS message: \" + textMessage.getText());\n            }\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n    }\n}\n<\/pre>\n<p>This configuration handles JMS messages and does not need any web layer or Tomcat server to run.<\/p>\n<h2 class=\"wp-block-heading\">4. Configuring Spring Boot Profiles<\/h2>\n<p>Spring Boot uses <strong>profiles<\/strong> to activate a specific set of configurations. Profiles can be set in several ways:<\/p>\n<h3 class=\"wp-block-heading\">4.1 Example Configuration for Different Profiles<\/h3>\n<p><strong>application-http.properties<\/strong><\/p>\n<pre class=\"brush:plain\">\nserver.port=8080\nspring.main.web-application-type=servlet\n<\/pre>\n<p><strong>application-jms.properties<\/strong><\/p>\n<pre class=\"brush:plain\">\nspring.main.web-application-type=none\n<\/pre>\n<p>Spring Boot automatically loads these based on the active profile set via <code>spring.profiles.active<\/code>.<\/p>\n<p><strong>application.properties<\/strong><\/p>\n<p>This is the default location to configure the active profile and application behavior.<\/p>\n<pre class=\"brush:plain\">\nspring.profiles.active=jms\nspring.main.web-application-type=none\n<\/pre>\n<p>This config ensures that no web context is initialized when using the <code>jms<\/code> profile.<\/p>\n<h2 class=\"wp-block-heading\">5. Testing the Profiles<\/h2>\n<p><strong>Running with JMS Profile<\/strong><\/p>\n<p>To run without starting Tomcat:<\/p>\n<pre class=\"brush:bash\">\nmvn spring-boot:run -Dspring-boot.run.profiles=jms\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre class=\"brush:plain\">\n2025-05-21T16:31:23.556+01:00  INFO 48065 --- [conditional-tomcat] [           main] c.j.e.ConditionalTomcatApplication       : The following 1 profile is active: \"jms\"\n2025-05-21T16:31:25.981+01:00  INFO 48065 --- [conditional-tomcat] [           main] c.j.e.config.JmsConfiguration            : JMS configuration initialized\n2025-05-21T16:31:26.210+01:00  INFO 48065 --- [conditional-tomcat] [           main] c.j.e.service.MessageListenerService     : Received JMS message: \"Hello from JMS!\"\n2025-05-21T16:31:39.475+01:00  INFO 48065 --- [conditional-tomcat] [           main] c.j.e.ConditionalTomcatApplication       : Started ConditionalTomcatApplication in 18.394 seconds (process running for 20.621)\n<\/pre>\n<p>The active profile is confirmed as &#8220;<strong>jms<\/strong>&#8220;, and the application starts up successfully without initializing embedded Tomcat, resulting in no Tomcat-related logs being displayed.<\/p>\n<p><strong>Running with HTTP Profile<\/strong><\/p>\n<p>To run the application with the <code>http<\/code> profile:<\/p>\n<pre class=\"brush:bash\">\nmvn spring-boot:run -Dspring-boot.run.profiles=http\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2025\/05\/http-profile.png\"><img decoding=\"async\" width=\"586\" height=\"280\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2025\/05\/http-profile.png\" alt=\"Output from running the Spring Boot example with the &quot;http&quot; profile to enable or disable embedded Tomcat\" class=\"wp-image-134326\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2025\/05\/http-profile.png 586w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2025\/05\/http-profile-300x143.png 300w\" sizes=\"(max-width: 586px) 100vw, 586px\" \/><\/a><\/figure>\n<\/div>\n<p>When the &#8220;<strong>http<\/strong>&#8221; profile is active, the application starts successfully with embedded Tomcat initialized, and Tomcat-related logs are displayed, confirming that the web server is up and ready to serve HTTP requests.<\/p>\n<p>Accessing <code>http:\/\/localhost:8080\/hello<\/code> returns:<\/p>\n<pre class=\"brush:plain\">\nHello from HTTP profile!\n<\/pre>\n<h2 class=\"wp-block-heading\">6. Conclusion<\/h2>\n<p>In conclusion, by leveraging Spring Boot profiles and the <code>spring.main.web-application-type<\/code> property, you can enable or disable embedded Tomcat as needed. This approach ensures your application only starts a web server when required, keeping it lightweight and tailored to specific runtime needs.<\/p>\n<h2 class=\"wp-block-heading\">7. Download the Source Code<\/h2>\n<p>This article explored how to enable or disable embedded Tomcat in Spring Boot based on active profiles.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2025\/05\/conditional-tomcat.zip\"><strong>spring boot enable disable embedded tomcat<\/strong><\/a>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In many Spring Boot applications, especially those that support multiple deployment modes, it is common to encounter different runtime environments. For instance, one mode might expose a RESTful API using an embedded Tomcat server, while another might rely purely on messaging (e.g., using JMS or Kafka) without needing any HTTP layer. In this article, we &hellip;<\/p>\n","protected":false},"author":128888,"featured_media":84,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[3995,3991,854,3992,3993,3994],"class_list":["post-133748","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-conditional-configuration","tag-embedded-tomcat","tag-spring-boot","tag-spring-boot-configuration","tag-spring-boot-exclude-autoconfiguration","tag-spring-profiles"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Enable or Disable Embedded Tomcat in Spring Boot Using Profiles - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Learn how to use Spring Boot to enable or disable embedded Tomcat conditionally based on active application profiles.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Enable or Disable Embedded Tomcat in Spring Boot Using Profiles - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Learn how to use Spring Boot to enable or disable embedded Tomcat conditionally based on active application profiles.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/web.facebook.com\/omos.aziegbe\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-27T18:09:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-27T18:09:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-tomcat-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Omozegie Aziegbe\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/OAziegbe\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Omozegie Aziegbe\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html\"},\"author\":{\"name\":\"Omozegie Aziegbe\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/7d3eac6e45542536e961129ae0fb453e\"},\"headline\":\"Enable or Disable Embedded Tomcat in Spring Boot Using Profiles\",\"datePublished\":\"2025-05-27T18:09:09+00:00\",\"dateModified\":\"2025-05-27T18:09:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html\"},\"wordCount\":650,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-tomcat-logo.jpg\",\"keywords\":[\"Conditional Configuration\",\"Embedded Tomcat\",\"Spring Boot\",\"Spring Boot Configuration\",\"Spring Boot Exclude AutoConfiguration\",\"Spring Profiles\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html\",\"name\":\"Enable or Disable Embedded Tomcat in Spring Boot Using Profiles - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-tomcat-logo.jpg\",\"datePublished\":\"2025-05-27T18:09:09+00:00\",\"dateModified\":\"2025-05-27T18:09:11+00:00\",\"description\":\"Learn how to use Spring Boot to enable or disable embedded Tomcat conditionally based on active application profiles.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-tomcat-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-tomcat-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Enable or Disable Embedded Tomcat in Spring Boot Using Profiles\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/7d3eac6e45542536e961129ae0fb453e\",\"name\":\"Omozegie Aziegbe\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/cropped-jcg_profile_pic-96x96.jpg\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/cropped-jcg_profile_pic-96x96.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/cropped-jcg_profile_pic-96x96.jpg\",\"caption\":\"Omozegie Aziegbe\"},\"description\":\"Omos Aziegbe is a technical writer and web\\\/application developer with a BSc in Computer Science and Software Engineering from the University of Bedfordshire. Specializing in Java enterprise applications with the Jakarta EE framework, Omos also works with HTML5, CSS, and JavaScript for web development. As a freelance web developer, Omos combines technical expertise with research and writing on topics such as software engineering, programming, web application development, computer science, and technology.\",\"sameAs\":[\"https:\\\/\\\/web.facebook.com\\\/omos.aziegbe\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/omosaziegbe\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/OAziegbe\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/omozegie-aziegbe\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Enable or Disable Embedded Tomcat in Spring Boot Using Profiles - Java Code Geeks","description":"Learn how to use Spring Boot to enable or disable embedded Tomcat conditionally based on active application profiles.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html","og_locale":"en_US","og_type":"article","og_title":"Enable or Disable Embedded Tomcat in Spring Boot Using Profiles - Java Code Geeks","og_description":"Learn how to use Spring Boot to enable or disable embedded Tomcat conditionally based on active application profiles.","og_url":"https:\/\/www.javacodegeeks.com\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_author":"https:\/\/web.facebook.com\/omos.aziegbe","article_published_time":"2025-05-27T18:09:09+00:00","article_modified_time":"2025-05-27T18:09:11+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-tomcat-logo.jpg","type":"image\/jpeg"}],"author":"Omozegie Aziegbe","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/OAziegbe","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Omozegie Aziegbe","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html"},"author":{"name":"Omozegie Aziegbe","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/7d3eac6e45542536e961129ae0fb453e"},"headline":"Enable or Disable Embedded Tomcat in Spring Boot Using Profiles","datePublished":"2025-05-27T18:09:09+00:00","dateModified":"2025-05-27T18:09:11+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html"},"wordCount":650,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-tomcat-logo.jpg","keywords":["Conditional Configuration","Embedded Tomcat","Spring Boot","Spring Boot Configuration","Spring Boot Exclude AutoConfiguration","Spring Profiles"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html","url":"https:\/\/www.javacodegeeks.com\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html","name":"Enable or Disable Embedded Tomcat in Spring Boot Using Profiles - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-tomcat-logo.jpg","datePublished":"2025-05-27T18:09:09+00:00","dateModified":"2025-05-27T18:09:11+00:00","description":"Learn how to use Spring Boot to enable or disable embedded Tomcat conditionally based on active application profiles.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-tomcat-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-tomcat-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/enable-or-disable-embedded-tomcat-in-spring-boot-using-profiles.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Enable or Disable Embedded Tomcat in Spring Boot Using Profiles"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/7d3eac6e45542536e961129ae0fb453e","name":"Omozegie Aziegbe","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/cropped-jcg_profile_pic-96x96.jpg","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/cropped-jcg_profile_pic-96x96.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/cropped-jcg_profile_pic-96x96.jpg","caption":"Omozegie Aziegbe"},"description":"Omos Aziegbe is a technical writer and web\/application developer with a BSc in Computer Science and Software Engineering from the University of Bedfordshire. Specializing in Java enterprise applications with the Jakarta EE framework, Omos also works with HTML5, CSS, and JavaScript for web development. As a freelance web developer, Omos combines technical expertise with research and writing on topics such as software engineering, programming, web application development, computer science, and technology.","sameAs":["https:\/\/web.facebook.com\/omos.aziegbe","https:\/\/www.linkedin.com\/in\/omosaziegbe\/","https:\/\/x.com\/https:\/\/twitter.com\/OAziegbe"],"url":"https:\/\/www.javacodegeeks.com\/author\/omozegie-aziegbe"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/133748","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/128888"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=133748"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/133748\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/84"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=133748"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=133748"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=133748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}