New Maven Project in IntelliJ

New Maven Project in IntelliJ

Reading Time: ~ 3 minutes

Let’s create a new Maven Project in IntelliJ!

It is quite easy.

4 Steps for creation of a Maven Project in IntelliJ

  1. Click on File > New > Project...

    creating the project - step1

  2. Now select Maven as  the project type and click Next. No need to select an archetype or such…
    creating the project - step2
  3. Fill in the fields with the values that fit your project:
    if you have a web domain use that in reverse order as the groupId
    as the artifactId you can put in the project name.
    (Just remember a groupId can contain several artifacts so make sure the artifactId is somewhat unique among your projects)
    Leave the version as is…
    creating the project - step3
  4. Finally you can use the already filled in values as the project name an directory where it should be created or change to something that you find better
    creating the project - step4

Some (helpful) extra configuration

I do use (at the moment) Java 8 on my projects and sometimes when I create a new project, IntelliJ insists in setting everything to Java 1.5 :/

There are 3 things I do at the beginning (which you can later add as defaults):

  1. Go to File > Settings > Build, Execution, Deployment > Compiler > Java Compiler or just type “Java Compiler” in the search.
    There is a table there which should contain your project Module and a Target bytecode version.
    Make sure it is set to 1.8
    Alternatively you can set the Project bytecode version to 1.8 (above the table)
    Set bytecode version to 1.8
  2. Go to File > Project Structure and make sure that under the Project tab, the option Project language level is set to 1.8
    project language level setting
    Make sure also that under the Modules tab, all of the modules of your project (should be only one if you just created) have the Language level dropdown in the Sources tab also set to 8
    project module language level setting
  3. Finally, I add these lines to my POM file (between the Project tags):
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

     

And there you go! I hope this helps you to set up your first maven project 🙂

Leave your opinion, start a discussion, share an experience or just a compliment...

%d bloggers like this: