NDY
NDY

Reputation: 3557

Maven + IntelliJ project settings reset

At the moment Im trying to learn a little bit about Maven and going into IntelliJ IDEA. I set up a project and created a jersey rest backend with hibernate and mysql. I used tomcat as web container. Everything works, but sometimes I recognise that some settings in my IntelliJ project settings are deleted. Perhaps it has something to do with Maven...?

The two problems I got:

  1. Sometimes my application context I set up in the tomcat configuration just disappears.
  2. I added the folder src/main/resources in the project settings, because I saved my hibernate config to this folder so maven deploys it in the war. I added also the src folder, because there are all my src files. But after some tomcat restarts, this directory disappears too and then all files in my src folder are marked with a red icon.

This is my pom:

    <groupId>ExampleProject</groupId>
<artifactId>ExampleProject</artifactId>
<version>1.0</version>
<packaging>war</packaging>

<dependencies>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-server</artifactId>
        <version>1.9</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-grizzly2</artifactId>
        <version>1.9.1</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-json</artifactId>
        <version>1.9</version>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.18</version>
    </dependency>

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

    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.1-api</artifactId>
        <version>1.0.0.Final</version>
    </dependency>

    <dependency>
        <groupId>ma.glasnost.orika</groupId>
        <artifactId>orika-core</artifactId>
        <version>1.4.0</version>
    </dependency>

</dependencies>

IntelliJ Tomcat Configuration

Project Settings / Module

Can someone help me and explain why this happens?

Upvotes: 1

Views: 3441

Answers (1)

Bastien Jansen
Bastien Jansen

Reputation: 8836

The "standard" layout in a Maven web app is:

src/
  main/
    java/
    resources/
    webapp/
      WEB-INF/
  test/
    java/
    resources/

Your screenshots indicate that your setup is a little different, that's why IntelliJ may be confused and acts strangely. I suggest you create your Maven project using a predefined archetype, then import it in IntelliJ (using File -> Open and selecting the root pom.xml). I've never had any problems using the standard Maven layout. Furthermore, it follows Maven's convention over configuration and it will be easier to understand for those who are used to standard Maven projects.

Upvotes: 3

Related Questions