lundi 9 janvier 2017

Java web app recommended project structure

I'm using IntelliJ to create one of my first web apps. I'd like to use Gradle to solve my dependencies. Depending on how I create the project, it is structured differently.

I was wondering whether there is a recommended project structure for web apps. Where to put the static pages? Where to put the classes? Where the other resources (like images)? And where to put other framework-specific files, like the build.gradle file?

Right now I see three alternatives:

If I create the project as a Java web application (File -> New Project -> check Java::JavaEE::Web Application -> Next etc...) I get the following project structure:

|-- WebApp.iml
|-- src
`-- web
    |-- WEB-INF
    |   `-- web.xml
    `-- index.jsp

If I create a Gradle project (File -> New Project -> check Gradle::Java and Gradle::Web -> Next etc...) I get the following structure:

|-- build
|   `-- tmp
|       `-- war
|           `-- MANIFEST.MF
|-- build.gradle
|-- GradleWebApp.iml
|-- out
|-- settings.gradle
`-- src
    `-- main
        `-- webapp
            `-- index.jsp

Before using IntelliJ I manually deployed a basic application to my local tomcat. The project structure was the following:

|-- WEB-INF
|   |-- classes
|   |   `-- servletsPkg
|   |       `-- AServlet.class
|   |-- src
|   |   `-- servletsPkg
|   |       `-- AServlet.java
|   `-- web.xml
|-- images
|   `-- an_image.jpg
|-- index.html
`-- styles.css




Aucun commentaire:

Enregistrer un commentaire