19
votes

I tried to create a maven webapp project in Intellij, it creates the maven folder structure like this:

-src
---main
------resources
------webapp

But it does not create the "java" folder. If i try to create it manually, when i right click the Java folder it does not give me the option "new Class" or "new package", just "new file" or "new folder".

How to make the IDE understand the folder as a java folder?

2
I suppose this is to enforce separation of your webapp from java code. I'd rather create a separate maven module for your java code and add it as dependency.Gyro Gearless

2 Answers

42
votes

You need to right click the java folder and choose the option:

Mark Directory As -> Source Root

2
votes

If it didn't create java directory, perhaps you didn't chose to create a java maven application when you opened/imported directory with project to idea. Anyways maven's structure is determined and java sources should be in java folder. You have to create a folder manually and mark it as java sources. Go to project settings(alt+ctrl+shift+s) -> Modules -> check your module in sources find your folder and Mark as Sources

mark as sources