{"id":70705,"date":"2017-11-20T13:00:05","date_gmt":"2017-11-20T11:00:05","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=70705"},"modified":"2017-11-20T10:36:55","modified_gmt":"2017-11-20T08:36:55","slug":"deploy-spring-application-without-web-xml-tomcat","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2017\/11\/deploy-spring-application-without-web-xml-tomcat.html","title":{"rendered":"How to Deploy Spring Application Without web.xml to Tomcat"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>Since the Servlet 3 specification <code>web.xml<\/code> is no longer needed for configuring your web application and has been replaced by using annotations. In this article, we will look at how to deploy a simple Spring-based application without <code>web.xml<\/code> to Tomcat 8.5.*.<\/p>\n<h2>Creating an Empty Application<\/h2>\n<p>Use the following command to create an empty web application using maven webapp archetype:<\/p>\n<pre class=\"brush:bash\">mvn archetype:generate -DgroupId=info.sanaulla -DartifactId=spring-tomcat-sample \r\n   -Dversion=1.0 -DarchetypeArtifactId=maven-archetype-webapp<\/pre>\n<p>Delete the <code>web.xml<\/code> created in <code>src\\main\\webapp\\WEB-INF<\/code> and then we need to update the <code>maven-war-plugin<\/code> not to fail if <code>web.xml<\/code> is missing, this can be done by updating the plugin information in the <code>build<\/code> tag as shown below:<\/p>\n<pre class=\"brush:xml\">&lt;plugin&gt;\r\n  &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;maven-war-plugin&lt;\/artifactId&gt;\r\n  &lt;version&gt;3.1.0&lt;\/version&gt;\r\n  &lt;executions&gt;\r\n    &lt;execution&gt;\r\n      &lt;id&gt;default-war&lt;\/id&gt;\r\n      &lt;phase&gt;prepare-package&lt;\/phase&gt;\r\n      &lt;configuration&gt;\r\n        &lt;failOnMissingWebXml&gt;false&lt;\/failOnMissingWebXml&gt;\r\n      &lt;\/configuration&gt;\r\n    &lt;\/execution&gt;\r\n  &lt;\/executions&gt;\r\n&lt;\/plugin&gt;<\/pre>\n<h2>Setting up dependencies<\/h2>\n<p>We would need the following dependencies added to the <code>pom.xml<\/code>:<\/p>\n<pre class=\"brush:xml\">&lt;dependency&gt;\r\n  &lt;groupId&gt;javax.servlet&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;javax.servlet-api&lt;\/artifactId&gt;\r\n  &lt;version&gt;4.0.0&lt;\/version&gt;\r\n  &lt;scope&gt;provided&lt;\/scope&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n  &lt;groupId&gt;org.springframework&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;spring-webmvc&lt;\/artifactId&gt;\r\n  &lt;version&gt;${spring.version}&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n  &lt;groupId&gt;org.springframework&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;spring-jdbc&lt;\/artifactId&gt;\r\n  &lt;version&gt;${spring.version}&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n  &lt;groupId&gt;org.thymeleaf&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;thymeleaf-spring5&lt;\/artifactId&gt;\r\n  &lt;version&gt;${thymeleaf.version}&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n  &lt;groupId&gt;nz.net.ultraq.thymeleaf&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;thymeleaf-layout-dialect&lt;\/artifactId&gt;\r\n  &lt;version&gt;${thymeleaf-layout-dialect.version}&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n  &lt;groupId&gt;com.fasterxml.jackson.core&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;jackson-databind&lt;\/artifactId&gt;\r\n  &lt;version&gt;${jackson.version}&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n  &lt;groupId&gt;com.h2database&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;h2&lt;\/artifactId&gt;\r\n  &lt;version&gt;${h2.version}&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n  &lt;groupId&gt;org.projectlombok&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;lombok&lt;\/artifactId&gt;\r\n  &lt;optional&gt;true&lt;\/optional&gt;\r\n  &lt;version&gt;${lombok.version}&lt;\/version&gt;\r\n&lt;\/dependency&gt;<\/pre>\n<p>And their corresponding version properties are given below:<\/p>\n<pre class=\"brush:xml\">&lt;properties&gt;\r\n  &lt;maven.compiler.target&gt;1.8&lt;\/maven.compiler.target&gt;\r\n  &lt;maven.compiler.source&gt;1.8&lt;\/maven.compiler.source&gt;\r\n  &lt;java.version&gt;1.8&lt;\/java.version&gt;\r\n\r\n  &lt;apache.commons.version&gt;3.6&lt;\/apache.commons.version&gt;\r\n  &lt;h2.version&gt;1.4.196&lt;\/h2.version&gt;\r\n  &lt;jackson.version&gt;2.9.2&lt;\/jackson.version&gt;\r\n  &lt;lombok.version&gt;1.16.18&lt;\/lombok.version&gt;\r\n  &lt;spring.version&gt;5.0.0.RELEASE&lt;\/spring.version&gt;\r\n  &lt;thymeleaf.version&gt;3.0.9.RELEASE&lt;\/thymeleaf.version&gt;\r\n  &lt;thymeleaf-layout-dialect.version&gt;2.2.1&lt;\/thymeleaf-layout-dialect.version&gt;\r\n&lt;\/properties&gt;<\/pre>\n<h2>Configuring H2 Embedded DB<\/h2>\n<p>Let us create a configuration bean for configuring our <code>DataSource<\/code> which is Embedded H2 and creating a <code>Bean<\/code> of type <code>NamedParameterJdbcTemplate<\/code>:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:java\">@Configuration\r\npublic class DBConfiguration {\r\n\r\n  @Bean\r\n  public DataSource dataSource() {\r\n    return new EmbeddedDatabaseBuilder()\r\n      .generateUniqueName(false)\r\n      .setName(\"testdb\")\r\n      .setType(EmbeddedDatabaseType.H2)\r\n      .addDefaultScripts()\r\n      .setScriptEncoding(\"UTF-8\")\r\n      .ignoreFailedDrops(true)\r\n      .build();\r\n  }\r\n\r\n  @Bean\r\n  public NamedParameterJdbcTemplate namedParamJdbcTemplate() {\r\n    NamedParameterJdbcTemplate namedParamJdbcTemplate = \r\n      new NamedParameterJdbcTemplate(dataSource());\r\n    return namedParamJdbcTemplate;\r\n  }\r\n}<\/pre>\n<p>Then we need a SQL script <code>schema.sql<\/code> which will set up the tables and <code>data.sql<\/code> will seed them with data each time the application is run. Let us create the corresponding files in <code>src\/main\/resources<\/code>:<\/p>\n<pre class=\"brush:java\">-- schema.sql\r\nDROP TABLE IF EXISTS person;\r\n\r\nCREATE TABLE person(\r\n  id NUMERIC IDENTITY PRIMARY KEY,\r\n  first_name VARCHAR(512) NOT NULL,\r\n  last_name VARCHAR(512) NOT NULL,\r\n  date_of_birth TIMESTAMP NOT NULL,\r\n  place_of_birth VARCHAR(512)\r\n);\r\n\r\n-- data.sql\r\nINSERT INTO person(first_name, last_name, date_of_birth, place_of_birth) \r\nVALUES ('First', 'Last', DATE '1990-02-21', 'Bangalore');\r\nINSERT INTO person(first_name, last_name, date_of_birth, place_of_birth) \r\nVALUES ('First2', 'Last2', DATE '1987-02-21', 'Mumbai');\r\nINSERT INTO person(first_name, last_name, date_of_birth, place_of_birth) \r\nVALUES ('First3', 'Last3', DATE '1996-02-21', 'Chennai');\r\nINSERT INTO person(first_name, last_name, date_of_birth, place_of_birth) \r\nVALUES ('First4', 'Last4', DATE '1978-02-21', 'Delhi');<\/pre>\n<h2>Creating an API Controller<\/h2>\n<p>Lets us create a model class <code>Person<\/code>:<\/p>\n<pre class=\"brush:java\">@Data\r\npublic class Person {\r\n  private Integer id;\r\n  private String firstName;\r\n  private String lastName;\r\n  private Date dateOfBirth;\r\n  private String placeOfBirth;\r\n}<\/pre>\n<p>And a corresponding DAO class <code>PersonDAO<\/code>:<\/p>\n<pre class=\"brush:java\">@Service\r\npublic class PersonDAO {\r\n\r\n  @Autowired NamedParameterJdbcTemplate jdbcTemplate;\r\n\r\n  public List&lt;Person&gt; getPersons(){\r\n    return jdbcTemplate.query(\"SELECT * FROM person\", \r\n      (ResultSet rs, int rowNum) -&gt; {\r\n        Person p = new Person();\r\n        p.setId(rs.getInt(\"id\"));\r\n        p.setFirstName(rs.getString(\"first_name\"));\r\n        p.setLastName(rs.getString(\"last_name\"));\r\n        p.setDateOfBirth(rs.getDate(\"date_of_birth\"));\r\n        p.setPlaceOfBirth(rs.getString(\"place_of_birth\"));\r\n        return p;\r\n    });\r\n  }\r\n}<\/pre>\n<p>The API controller is as shown below:<\/p>\n<pre class=\"brush:java\">@RestController\r\n@RequestMapping(\"\/api\/persons\")\r\npublic class ApiController {\r\n\r\n  @Autowired PersonDAO personDao;\r\n\r\n  @GetMapping\r\n  public ResponseEntity&lt;?&gt; getPersons(){\r\n    return ResponseEntity.ok(personDao.getPersons());\r\n  }\r\n}<\/pre>\n<h2>Deploying app to Tomcat<\/h2>\n<p>I assume that you have downloaded Tomcat and extracted to your file system. For development purpose, I prefer to update <code>server.xml<\/code> to configure the context and point to the exploded war directory as shown below:<\/p>\n<pre class=\"brush:xml\">&lt;Context path=\"\/sample\" reloadable=\"true\" \r\n  docBase=\"G:\\samples\\spring-tomcat-sample\\target\\spring-tomcat-sample\" \/&gt;<\/pre>\n<p>For production-related deployments, you can upload the war on to the server.<\/p>\n<p>So once you start the server, you can verify if the app has been deployed correctly by visiting the API URL <a href=\"http:\/\/localhost:8080\/sample\/api\/persons\" rel=\"nofollow\">http:\/\/localhost:8080\/sample\/api\/persons<\/a> in the browser to get the data as shown below:<br \/>\n<a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/11-1.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-70709\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/11-1.png\" alt=\"\" width=\"289\" height=\"327\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/11-1.png 289w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/11-1-265x300.png 265w\" sizes=\"(max-width: 289px) 100vw, 289px\" \/><\/a><a href=\"https:\/\/sanaulla.files.wordpress.com\/2017\/11\/11.png\"><\/a><\/p>\n<h2>Configuring Thymeleaf<\/h2>\n<p>Let us now configure <a href=\"www.thymeleaf.org\">Thymeleaf<\/a> as our templating engine to serve the UI for our application. Configuring it requires the following bean definitions:<br \/>\n\u2013 Technique for resolving the templates. There are many possibilities and we will use Classpath based template resolver<br \/>\n\u2013 Create an instance of <code>SpringTemplateEngine<\/code> and set the template resolver technique<br \/>\n\u2013 Setup Spring\u2019s <code>ViewResolver<\/code> to use the <code>SpringTemplateEngine<\/code><\/p>\n<pre class=\"brush:java\">@Configuration\r\npublic class ViewConfiguration {\r\n\r\n  @Bean\r\n  public ClassLoaderTemplateResolver templateResolver() {\r\n    ClassLoaderTemplateResolver templateResolver = \r\n      new ClassLoaderTemplateResolver();\r\n    templateResolver.setPrefix(\"templates\/\");\r\n    templateResolver.setSuffix(\".html\");\r\n    templateResolver.setTemplateMode(TemplateMode.HTML);\r\n    templateResolver.setCacheable(false);\r\n    return templateResolver;\r\n  }\r\n\r\n  @Bean\r\n  public SpringTemplateEngine templateEngine() {\r\n    SpringTemplateEngine templateEngine = \r\n      new SpringTemplateEngine();\r\n    templateEngine.setTemplateResolver(templateResolver());\r\n    templateEngine.addDialect(new LayoutDialect());\r\n    return templateEngine;\r\n  }\r\n\r\n  @Bean\r\n  public ViewResolver viewResolver() {\r\n    ThymeleafViewResolver viewResolver = \r\n      new ThymeleafViewResolver();\r\n    viewResolver.setTemplateEngine(templateEngine());\r\n    viewResolver.setCharacterEncoding(\"UTF-8\");\r\n    return viewResolver;\r\n  }\r\n\r\n}<\/pre>\n<h2>Creating View Controller<\/h2>\n<p>Let us create a simple controller which will serve our UI templates:<\/p>\n<pre class=\"brush:java\">@Controller\r\n@RequestMapping(\"\/\")\r\npublic class ViewController {\r\n\r\n  @Autowired PersonDAO personDao;\r\n\r\n  @GetMapping\r\n  public String index(Model model) {\r\n    model.addAttribute(\"persons\", personDao.getPersons());\r\n    return \"index\";\r\n  }\r\n}<\/pre>\n<h2>Creating a Thymeleaf Based Template<\/h2>\n<p>We need to create a template <code>index.html<\/code> which is returned from the above controller:<\/p>\n<pre class=\"brush:xml\">&lt;!DOCTYPE html&gt;\r\n&lt;html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" \r\n  xmlns:th=\"http:\/\/www.thymeleaf.org\"&gt;\r\n  &lt;head&gt;\r\n    &lt;link rel=\"stylesheet\" \r\n      href=\"https:\/\/bootswatch.com\/4\/cerulean\/bootstrap.min.css\" \/&gt;\r\n  &lt;\/head&gt;\r\n  &lt;body&gt;\r\n    &lt;nav class=\"navbar navbar-expand-lg navbar-dark bg-primary\"&gt;\r\n      &lt;a class=\"navbar-brand\" href=\"#\"&gt;Spring on Tomcat&lt;\/a&gt;\r\n    &lt;\/nav&gt;\r\n    &lt;div class=\"container\"&gt;\r\n      &lt;div class=\"page-header\"&gt;&lt;h1&gt;Spring on Tomcat&lt;\/h1&gt;&lt;\/div&gt;\r\n      &lt;div class=\"row\"&gt;\r\n        &lt;div class=\"col\"&gt;\r\n          &lt;ul class=\"list-group\"&gt;\r\n            &lt;li class=\"list-group-item\" th:each=\"p : ${persons}\"&gt;\r\n            [[${p.firstName}]] [[${p.lastName}]], \r\n            Date Of Birth: [[${#dates.format(p.dateOfBirth, 'dd\/MMM\/yyyy')}]]\r\n            Place: [[${p.placeOfBirth}]]\r\n            &lt;\/li&gt;\r\n          &lt;\/ul&gt;\r\n        &lt;\/div&gt;\r\n      &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n    &lt;script src=\"https:\/\/bootswatch.com\/_vendor\/jquery\/dist\/jquery.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;script src=\"https:\/\/bootswatch.com\/_vendor\/popper.js\/dist\/umd\/popper.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;script src=\"https:\/\/bootswatch.com\/_vendor\/bootstrap\/dist\/js\/bootstrap.min.js\"&gt;&lt;\/script&gt;\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<h2>Conclusion<\/h2>\n<p>In this article, we looked at configuring a simple Spring MVC based application without <code>web.xml<\/code> (without using Spring Boot) and deploying it to Tomcat. We also configured <code>Thymeleaf<\/code> to render our UI templates. The complete code for this can be found <a href=\"https:\/\/github.com\/sanaulla123\/samples\/tree\/master\/spring-tomcat-sample\">here<\/a><\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>Published on Java Code Geeks with permission by Mohamed Sanaulla, partner at our <a href=\"http:\/\/www.javacodegeeks.com\/join-us\/jcg\/\" target=\"_blank\" rel=\"noopener\">JCG program<\/a>. See the original article here: <a href=\"https:\/\/sanaulla.info\/2017\/11\/18\/how-to-deploy-spring-application-without-web-xml-to-tomcat\/\" target=\"_blank\" rel=\"noopener\">How to Deploy Spring Application Without web.xml to Tomcat<\/a><\/p>\n<p>Opinions expressed by Java Code Geeks contributors are their own.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Since the Servlet 3 specification web.xml is no longer needed for configuring your web application and has been replaced by using annotations. In this article, we will look at how to deploy a simple Spring-based application without web.xml to Tomcat 8.5.*. Creating an Empty Application Use the following command to create an empty web &hellip;<\/p>\n","protected":false},"author":24,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[30],"class_list":["post-70705","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-spring"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Deploy Spring Application Without web.xml to Tomcat - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Introduction Since the Servlet 3 specification web.xml is no longer needed for configuring your web application and has been replaced by using\" \/>\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\/2017\/11\/deploy-spring-application-without-web-xml-tomcat.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Deploy Spring Application Without web.xml to Tomcat - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Introduction Since the Servlet 3 specification web.xml is no longer needed for configuring your web application and has been replaced by using\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2017\/11\/deploy-spring-application-without-web-xml-tomcat.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:published_time\" content=\"2017-11-20T11:00:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-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=\"Mohamed Sanaulla\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mohamed Sanaulla\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/deploy-spring-application-without-web-xml-tomcat.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/deploy-spring-application-without-web-xml-tomcat.html\"},\"author\":{\"name\":\"Mohamed Sanaulla\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/d27ef53124d64097c81168263af5a7f7\"},\"headline\":\"How to Deploy Spring Application Without web.xml to Tomcat\",\"datePublished\":\"2017-11-20T11:00:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/deploy-spring-application-without-web-xml-tomcat.html\"},\"wordCount\":451,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/deploy-spring-application-without-web-xml-tomcat.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"keywords\":[\"Spring\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/deploy-spring-application-without-web-xml-tomcat.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/deploy-spring-application-without-web-xml-tomcat.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/deploy-spring-application-without-web-xml-tomcat.html\",\"name\":\"How to Deploy Spring Application Without web.xml to Tomcat - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/deploy-spring-application-without-web-xml-tomcat.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/deploy-spring-application-without-web-xml-tomcat.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2017-11-20T11:00:05+00:00\",\"description\":\"Introduction Since the Servlet 3 specification web.xml is no longer needed for configuring your web application and has been replaced by using\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/deploy-spring-application-without-web-xml-tomcat.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/deploy-spring-application-without-web-xml-tomcat.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/deploy-spring-application-without-web-xml-tomcat.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"spring-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/deploy-spring-application-without-web-xml-tomcat.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\":\"How to Deploy Spring Application Without web.xml to Tomcat\"}]},{\"@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\\\/d27ef53124d64097c81168263af5a7f7\",\"name\":\"Mohamed Sanaulla\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/64131fe9e9472b8852abf595cbbf3a8a2a5e86569fa1349eed92b2a32f9104c1?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/64131fe9e9472b8852abf595cbbf3a8a2a5e86569fa1349eed92b2a32f9104c1?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/64131fe9e9472b8852abf595cbbf3a8a2a5e86569fa1349eed92b2a32f9104c1?s=96&d=mm&r=g\",\"caption\":\"Mohamed Sanaulla\"},\"sameAs\":[\"http:\\\/\\\/blog.sanaulla.info\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Mohamed-Sanaulla\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Deploy Spring Application Without web.xml to Tomcat - Java Code Geeks","description":"Introduction Since the Servlet 3 specification web.xml is no longer needed for configuring your web application and has been replaced by using","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\/2017\/11\/deploy-spring-application-without-web-xml-tomcat.html","og_locale":"en_US","og_type":"article","og_title":"How to Deploy Spring Application Without web.xml to Tomcat - Java Code Geeks","og_description":"Introduction Since the Servlet 3 specification web.xml is no longer needed for configuring your web application and has been replaced by using","og_url":"https:\/\/www.javacodegeeks.com\/2017\/11\/deploy-spring-application-without-web-xml-tomcat.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2017-11-20T11:00:05+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","type":"image\/jpeg"}],"author":"Mohamed Sanaulla","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Mohamed Sanaulla","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/deploy-spring-application-without-web-xml-tomcat.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/deploy-spring-application-without-web-xml-tomcat.html"},"author":{"name":"Mohamed Sanaulla","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/d27ef53124d64097c81168263af5a7f7"},"headline":"How to Deploy Spring Application Without web.xml to Tomcat","datePublished":"2017-11-20T11:00:05+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/deploy-spring-application-without-web-xml-tomcat.html"},"wordCount":451,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/deploy-spring-application-without-web-xml-tomcat.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","keywords":["Spring"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2017\/11\/deploy-spring-application-without-web-xml-tomcat.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/deploy-spring-application-without-web-xml-tomcat.html","url":"https:\/\/www.javacodegeeks.com\/2017\/11\/deploy-spring-application-without-web-xml-tomcat.html","name":"How to Deploy Spring Application Without web.xml to Tomcat - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/deploy-spring-application-without-web-xml-tomcat.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/deploy-spring-application-without-web-xml-tomcat.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2017-11-20T11:00:05+00:00","description":"Introduction Since the Servlet 3 specification web.xml is no longer needed for configuring your web application and has been replaced by using","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/deploy-spring-application-without-web-xml-tomcat.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2017\/11\/deploy-spring-application-without-web-xml-tomcat.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/deploy-spring-application-without-web-xml-tomcat.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","width":150,"height":150,"caption":"spring-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/deploy-spring-application-without-web-xml-tomcat.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":"How to Deploy Spring Application Without web.xml to Tomcat"}]},{"@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\/d27ef53124d64097c81168263af5a7f7","name":"Mohamed Sanaulla","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/64131fe9e9472b8852abf595cbbf3a8a2a5e86569fa1349eed92b2a32f9104c1?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/64131fe9e9472b8852abf595cbbf3a8a2a5e86569fa1349eed92b2a32f9104c1?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/64131fe9e9472b8852abf595cbbf3a8a2a5e86569fa1349eed92b2a32f9104c1?s=96&d=mm&r=g","caption":"Mohamed Sanaulla"},"sameAs":["http:\/\/blog.sanaulla.info"],"url":"https:\/\/www.javacodegeeks.com\/author\/Mohamed-Sanaulla"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/70705","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\/24"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=70705"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/70705\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/240"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=70705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=70705"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=70705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}