Aod Ren
Aod Ren

Reputation: 679

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.

Upvotes: 0

Views: 769

Answers (2)

Sumit Yadav
Sumit Yadav

Reputation: 1

Yup I Got solution (how to create web.xml in maven NetBeans 12.0 or later)

After making web application in maven NetBeans

1) Right click on WEB-INF Folder -> New -> Other

after clicking on other.. a window will popup in that choose : WEB folder in category

after choosing WEB on right corresponding file type will open

in that select: Standard Deployment Descriptor(web.xml)

and now u have it enjoy .....

[My first Answer on Stack Overflow :)]

Upvotes: 0

ernest_k
ernest_k

Reputation: 45319

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.

Upvotes: 1

Related Questions