user2070369
user2070369

Reputation: 4128

Cannot add Servlet in a Maven Project

I'm testing IntelliJ with a Maven Project, it creates the Project fine, the problem is that I don't see the option to add a Servlet, and i don't see an option to add a package eather. just JSP and JSF pages, this is the sub-menu I get, how can I add a servlet and a package?

Anexed screenshot

Upvotes: 1

Views: 1429

Answers (3)

Extendo
Extendo

Reputation: 1

in resources create a folder java in that folder create a package and in that package create a servlet

structure

Upvotes: 0

Anshu Shekhar
Anshu Shekhar

Reputation: 115

I was experimenting a bit and came across a scenario which may be helpful for someone. I created a directory main\java, which was created as a maven source directories as suggested by Intellij by default as shown in image.main\java Then i marked src as source directory and i do not get option to create new servlet under created java directory.
So in this particular case if you want to create servlet then first go to, "Mark directory as > Unmark as sources root". Now you can create servlet inside java directory as well.

Upvotes: 2

Ivaylo D. Ivanov
Ivaylo D. Ivanov

Reputation: 3859

This is because the folder on which you're invoking the context menu is not marked as a "source" folder.

One way of marking it is to right-click on it (in your case the "java" folder) and choose "Mark Directory As > Sources Root".

Upvotes: 3

Related Questions