Aod Ren Aod Ren -3 years ago 117
Java Question

Isn't web.xml supposed to be included when building maven project ? NetBeans

I made a new Maven project with Netbeans. There is a

pom.xml
in which i added:

<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.24</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.1.0.Final</version>
</dependency>

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>

</dependencies>


Is it normal if I don't have a web.xml in my project tree after building the project or should i treat the glassfish.xml just the same ?

enter image description here

I wonder if I didn't messed up things.

Answer Source

Java EE 6 made web.xml optional (traded in for a bunch of annotation-based configurations). If maven knows that Java EE 6 is the version, then it won't complain about a missing web.xml.

You should be able to configure for the most part using annotations. For portability's sake, use web.xml IF NEEDED rather than relying on vendor-specific configuration files.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download