• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Spring Boot - WAR/JAR  RSS feed

 
Ranch Hand
Posts: 370
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Spring Boot applications, the output file is a jar which is executed. I have few queries regarding Spring Boot apps:

1. As this is a jar file, then where do we have web.xml or other jee web app specific files such as filters in case we have defined some of the filters?

2. How the tomcat is embedded inside the jar and how does it serve as a servlet container inside a jar?
 
Ranch Hand
Posts: 118
1
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As the spring boot followed the new servlet specifications, where we don't need to define web.xml file.
You can configure all these things which you mentioned(in web.xml) through java files as well.
 
Bartender
Posts: 19816
93
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think that everything possible in a web.xml file can be done using annotated Java code. Most cases, including the common ones can, but as I recall, there are some configuration options that don't match up to specific Java code elements, so there's nothing to annotate.

The Spring Boot build process runs Maven, I believe, and part of the process involves building a WAR, which will then be pre-installed into the embedded Tomcat server. The proper location for web.xml, whether Spring Boot or otherwise is /WEB-INF/web.xml. In the case of a Maven build, you'd place the prototype file in the src/main/webapps/WEB-INF/web.xml file.

Since a web.xml is an override to annotations, if you use it, you only need to include stuff that either isn't handled by a Java code annotation or where the code annotation doesn't match the setting you actually want. If you don't have anything that requires that, omit the web.xml file from your source code.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!