14

What is the difference between Java projects having pom.xml and web.xml? Can projects have both these configurations at the same time?

TechSpellBound
  • 2,505
  • 6
  • 25
  • 36

6 Answers6

23

They're completely compatible. As a matter of fact, they perform completely unrelated tasks.

pom.xml is the configuration file for Maven projects. One of its goals is to provide assistance in the compilation and building of a project when using Maven. You can think of it as an ant build.xml file or a makefile Make file if you're not familiar to Maven (actually, it can provide a lot more functionality)

web.xml is the Java EE web application deployment descriptor, where you specify for instance servlets, servlet mappings and other aspects of a webapp.

Community
  • 1
  • 1
Xavi López
  • 27,550
  • 11
  • 97
  • 161
13

The two files have nothing to do with each other.

  • pom.xml - Maven configuration file. Controls the build process for the project
  • web.xml - Web application configuration file. Controls the deployment and configuration of the web application

The POM file really shouldn't be deployed with the application, its just for the build process.

Perception
  • 79,279
  • 19
  • 185
  • 195
8

web.xml is an indicator that the project is running in some kind of servlet container (possibly even a full-fledged Java EE container).

pom.xml is an indicator that the project is built using the Maven build system.

Those two things are entirely orthogonal, so any given project can have none, one or both of them.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
4

The Pom defines any dependancy libraries, it is part of Maven. This tells maven what jar files to download and store in the lib folder of your site.

Web xml is how your web project is configured.

They can both coexist as they do different things.

Davos555
  • 1,974
  • 15
  • 23
  • Hi @Davos555, where do I copy this code org.springframework.boot spring-boot-starter-remote-shell in POM.xml or web.xml, as you have mentioned, the code should go to POM.xml, correct? just to clarify please! thanks – Java.beginner Jan 15 '15 at 13:57
  • 1
    POM as this is used by Maven to find the dependencies you need. – Davos555 Jan 15 '15 at 16:08
3

POM stands for "Project Object Model". It is an XML representation of a Maven project held in a file named pom.xml. http://maven.apache.org/pom.html

yes you can have both configurations at the same time.

Euclides Mulémbwè
  • 1,677
  • 11
  • 18
0

The pom.xml is for configure your project with Maven.

The web.xml is use in all Java EE project under Tomcat for example.

You can use both, Maven is for compile and deploy your project, Tomcat is your server.

ke20
  • 665
  • 4
  • 19